Prime - Amber Tweaks and Scripting API

Forum for alternative clients, mods & discussions on the same.

Re: Prime - Amber Tweaks and Scripting API

Postby kacper022 » Tue Feb 28, 2017 8:24 am

Fostik wrote:And btw, im very bad in coding, so there are some requests:
A way to differ meat.
Some way to exit flower menu(or how can i?)


Fostik, try add "closeFlower()" to your code.
kacper022
 
Posts: 4
Joined: Fri Feb 24, 2012 6:38 pm

Re: Prime - Amber Tweaks and Scripting API

Postby ydex » Wed Mar 01, 2017 12:16 am

I would like to place stockpiles next to my beehive. something like

var coords=getCoords(beehive)-1;
placeStockpile("straw",coords) ;

but since placeStockpile and many other comands need coords in x,y format it doesnt seam to work?
Is there a way to get the x and y coords separatly?
bold
User avatar
ydex
 
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Prime - Amber Tweaks and Scripting API

Postby Fostik » Wed Mar 01, 2017 1:00 am

ydex wrote:I would like to place stockpiles next to my beehive. something like

var coords=getCoords(beehive)-1;
placeStockpile("straw",coords) ;

but since placeStockpile and many other comands need coords in x,y format it doesnt seam to work?
Is there a way to get the x and y coords separatly?



Function getCoords() returns only player coords.
I prefer use getMapObjects() and filter then. But this is shit for script speed :)

So, placeStockpile() requires item, x and y, not object.
Try something like
Code: Select all
placeStockpile("straw",coords.Coords.x,coords.Coords.y) ;

Image
Known as zunzon. Contact discord: zunzon.
User avatar
Fostik
 
Posts: 2219
Joined: Tue Jul 05, 2011 4:08 pm
Location: EU

Re: Prime - Amber Tweaks and Scripting API

Postby foomanchu » Wed Mar 01, 2017 1:54 am

Paradoxs wrote:
Thedrah wrote:is there any support for combat? such as knowing openers of yourself and opponent
and the new fishing requires the use of clicking on a window, any chance for some help? :D


Not yet, I'll work on it, I still dont have a character thats combat safe to be able to stand still and collect data to mess with combat. and test combat controls. SInce iv been gone im pretty behind. Its a eventual goal though


you can just spar one of your alts if you want to play around with combat stuff script wise
pretty much what i did
foomanchu
 
Posts: 121
Joined: Wed Jun 29, 2011 6:13 am

Re: Prime - Amber Tweaks and Scripting API

Postby Thedrah » Wed Mar 01, 2017 11:53 pm

how am i suppose to stop a script? using the login.js to log in on a character but it's stuck in a loop that won't break.
as far as i can tell, i'm suppose to use 'exit();' to end at the next loop. it does not for me. i've been trying to debug it for an hour or so but login just keeps looping

with this script, it just keeps repeating 'damn' endlessly :cry:
(i took out my login info for security)
Code: Select all
var LoginAttempts = 0;
var CharacterSelectAttempts = 0;


function main(){
    CheckLogin();
    CheckChar();
    Checkgame();
   print("damn");
   exit();
}

function CheckLogin(){
    if(getMenu("login")){
        print("Attempting to login");
        if(LoginAttempts < 10) {
            if (login(Username, Password)) {
                print("Logged in under: " + Username);
            } else {
                print("Failed to login(" + LoginAttempts + ")");
                LoginAttempts += 1;
            }
        }else{
            print("Failed to login, script terminating");
            Exit();
        }
    }
}

function CheckChar(){
    if(getMenu("char")){
        print("Attempting to select character");
        if(CharacterSelectAttempts < 10) {
            if (selectCharacter(Character)) {
                print("Selected Character: " + Character);
            } else {
                print("Could not find character " + Character + " (" + CharacterSelectAttempts + ")");
                CharacterSelectAttempts += 1;
            }
        }else{
            print("Failed to select " + Character);
            print("Do they exist? Script terminating");
            Exit();
        }
    }
}

function Checkgame(){
    if(getMenu("game")){
        print("found game!");
        print("login script example finished!");
        print("logging out");
        logout();
        print("Terminating Script");
        exit();
    }
}


edit: not using the login script seems to work great, guess i can't be lazy with logging in now hehe
edit 2: #loadlib is finicky, has to be in the same folder to load and if it has a main function, it loops instead of the loading file. maybe i should instead put the basic functions like nearest object from list into the api.js to make it simple...
  ▲
▲ ▲
Thedrah
 
Posts: 936
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Thu Mar 02, 2017 3:26 am

Thedrah wrote:edit: not using the login script seems to work great, guess i can't be lazy with logging in now hehe
edit 2: #loadlib is finicky, has to be in the same folder to load and if it has a main function, it loops instead of the loading file. maybe i should instead put the basic functions like nearest object from list into the api.js to make it simple...


There's a big in the way I handle the login script, its on my to-do to redo before next release.

Loadlib is indeed a bit annoying to work with, its being reworked. When I tested it it worked with folders though.

You can't have a main function anywhere but once, this doesnt just apply to my API this applies in java, C++ ect. The main can only exit once for a reason. its the start of your script. this is not a bug.

I will be reworking load lib, but mostly making it conform more with javascript rather than the system we have now.

kacper022 wrote:How can I get free solts in inventory? :oops:


Not yet implemented by on its way next release
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby RedSkies » Thu Mar 02, 2017 4:56 am

Hey - love it so far. Been making a couple basic scripts without too much trouble, except for one thing. I'm not sure if I'm using it wrong, but the sendChat() function doesn't seem to work for me.

I've tried a number of variations but none seem to work:
sendChat("text here");
sendChat("text here",Channel.Area);
sendChat("text here,Channel.Area,"Username");

as well as several others. Am I doing something wrong?
Thanks :D
jorb wrote:I hereby forbid you from using it.
User avatar
RedSkies
 
Posts: 102
Joined: Sat Dec 10, 2016 5:59 am

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Thu Mar 02, 2017 5:19 am

RedSkies wrote:Hey - love it so far. Been making a couple basic scripts without too much trouble, except for one thing. I'm not sure if I'm using it wrong, but the sendChat() function doesn't seem to work for me.

I've tried a number of variations but none seem to work:
sendChat("text here");
sendChat("text here",Channel.Area);
sendChat("text here,Channel.Area,"Username");

as well as several others. Am I doing something wrong?
Thanks :D



sendChat was renamed chat a while back
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby roskuwacz » Thu Mar 02, 2017 2:34 pm

Is there a possibility to get into buildings? Function PfClick and click do not work well is any other option?

Also a function which will read from specific chat will be usefull.
All great things are simple, and many can be expressed in single words: freedom, justice, honor, duty, mercy, hope. - Winston Churchill
User avatar
roskuwacz
 
Posts: 133
Joined: Sun Apr 10, 2011 2:33 pm

Re: Prime - Amber Tweaks and Scripting API

Postby RedSkies » Thu Mar 02, 2017 3:02 pm

Paradoxs wrote:
RedSkies wrote:Hey - love it so far. Been making a couple basic scripts without too much trouble, except for one thing. I'm not sure if I'm using it wrong, but the sendChat() function doesn't seem to work for me.

I've tried a number of variations but none seem to work:
sendChat("text here");
sendChat("text here",Channel.Area);
sendChat("text here,Channel.Area,"Username");

as well as several others. Am I doing something wrong?
Thanks :D



sendChat was renamed chat a while back


Thanks a bunch! Is there somewhere these changes are documented? I've been using the GitHub readme you have linked on the front page.
jorb wrote:I hereby forbid you from using it.
User avatar
RedSkies
 
Posts: 102
Joined: Sat Dec 10, 2016 5:59 am

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Claude [Bot] and 91 guests