wooo got my first 'script' running. harvests nearby barley
modified your method, boredom, that would find nearest object so it would select from a list such as
g.mapObjectRightClick(getNearestMapObjectfromList(g.getMapObjects('barley')).id);
it worked, now i just run that from a loop ^^
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Will think about it.Granger wrote:Crafting/building selector of custom clients would be nice (icon and name, sorted alphabetical, searchable by typing, cursor up/down highlights, enter selects), preferably with the ability to drag entries into belts.b0r3d0m wrote:GUI was already proposed few pages before. I need to decide how it should look like first.windmaker wrote:what about implement a window interface inside of the game? then each button can call a function inside of bot.
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Congratulations!Thedrah wrote:wooo got my first 'script' running. harvests nearby barley
modified your method, boredom, that would find nearest object so it would select from a list such as
g.mapObjectRightClick(getNearestMapObjectfromList(g.getMapObjects('barley')).id);
it worked, now i just run that from a loop ^^
Write another script then
-
Kuczmik
- Posts: 4
- Joined: Tue Apr 26, 2016 3:20 pm
Re: Scrifen -- Hafen scripting API
Could someone explain to me how use "mapObjectRightClick(id)" . I wrote a piece of code but it does not work
:
Code: Select all
function abc()
{
sleep(5000);
var clayStockpile = g.getMapObjects('stockpile-clay');
g.mapObjectRightClick(id)
sleep(5000);
g.takeItemFromStockpile();
}-
windmaker
- Posts: 1855
- Joined: Thu Mar 29, 2012 7:08 am
- Location: in the forum where some mods are fags.
Re: Scrifen -- Hafen scripting API
fix'd i guessKuczmik wrote:Could someone explain to me how use "mapObjectRightClick(id)" . I wrote a piece of code but it does not work:
Code: Select all
function abc() { sleep(5000); var clayStockpile = g.getMapObjects('stockpile-clay'); g.mapObjectRightClick(clayStockpile[0].id) sleep(5000); g.takeItemFromStockpile(); }
fyi : clayStockpile is an array who have all stockpiles in the map. so u need iterate it or get the first. if u need
#swag-
Kuczmik
- Posts: 4
- Joined: Tue Apr 26, 2016 3:20 pm
Re: Scrifen -- Hafen scripting API
Thank you very much, now works finewindmaker wrote:fix'd i guessKuczmik wrote:Could someone explain to me how use "mapObjectRightClick(id)" . I wrote a piece of code but it does not work:
Code: Select all
function abc() { sleep(5000); var clayStockpile = g.getMapObjects('stockpile-clay'); g.mapObjectRightClick(clayStockpile[0].id) sleep(5000); g.takeItemFromStockpile(); }
fyi : clayStockpile is an array who have all stockpiles in the map. so u need iterate it or get the first. if u need
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Also I don't think that you should sleep 5 seconds before taking any actions.
-
windmaker
- Posts: 1855
- Joined: Thu Mar 29, 2012 7:08 am
- Location: in the forum where some mods are fags.
Re: Scrifen -- Hafen scripting API
the walking have some problems. so or make a sleep or make a finishFP function (or wathever what is)b0r3d0m wrote:Also I don't think that you should sleep 5 seconds before taking any actions.
#swag-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
See the `waitForPf` function.windmaker wrote:the walking have some problems. so or make a sleep or make a finishFP function (or wathever what is)b0r3d0m wrote:Also I don't think that you should sleep 5 seconds before taking any actions.
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
is there a way to have the script use 'feast' at a table?
edit: a way to get the stats of an animal? with name of stat with the number? if so, i want to make a bot that would check each animal for stats and record them to a txt file, or better yet, modify an excel sheet
and is there a mining option? with possible hardness information (% per mining tick). maybe what kind of mine wall i'm digging but i can check by looking at the rock that falls out. i hope to be able to have a script to do simple mining in search of minerals
possible for a simple left click on a tile would solve most cases
edit again: can't use highlighted objects due to error
another edit: is there a way to get an array of items in study? and any way to get the quality of an item? even if that is only the item that is on the mouse/in hand?
edit: a way to get the stats of an animal? with name of stat with the number? if so, i want to make a bot that would check each animal for stats and record them to a txt file, or better yet, modify an excel sheet
and is there a mining option? with possible hardness information (% per mining tick). maybe what kind of mine wall i'm digging but i can check by looking at the rock that falls out. i hope to be able to have a script to do simple mining in search of minerals
possible for a simple left click on a tile would solve most cases
edit again: can't use highlighted objects due to error
Code: Select all
java.lang.ClassCastException: org.mozilla.javascript.UniqueTag cannot be cast to org.mozilla.javascript.Function
at haven.Evaluator.call(Evaluator.java:139)
at haven.ChatUI$MultiChat.lambda$uimsg$0(ChatUI.java:805)
at haven.Evaluator.lambda$new$0(Evaluator.java:39)
at java.lang.Thread.run(Unknown Source)
▲
▲ ▲
▲ ▲