Scrifen -- Hafen scripting API

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

Re: Scrifen -- Hafen scripting API

Postby Thedrah » Wed May 04, 2016 12:00 pm

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: 936
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Wed May 04, 2016 12:21 pm

Granger wrote:
b0r3d0m wrote:
windmaker wrote:what about implement a window interface inside of the game? then each button can call a function inside of bot.

GUI was already proposed few pages before. I need to decide how it should look like first.


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.

Will think about it.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Wed May 04, 2016 12:22 pm

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 ^^

Congratulations!

Write another script then :)
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby Kuczmik » Wed May 04, 2016 9:29 pm

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();
}
User avatar
Kuczmik
 
Posts: 4
Joined: Tue Apr 26, 2016 3:20 pm

Re: Scrifen -- Hafen scripting API

Postby windmaker » Wed May 04, 2016 9:37 pm

Kuczmik 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();
}

fix'd i guess

fyi : clayStockpile is an array who have all stockpiles in the map. so u need iterate it or get the first. if u need
Image #swag
User avatar
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

Postby Kuczmik » Wed May 04, 2016 9:43 pm

windmaker wrote:
Kuczmik 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();
}

fix'd i guess

fyi : clayStockpile is an array who have all stockpiles in the map. so u need iterate it or get the first. if u need


Thank you very much, now works fine :roll:
User avatar
Kuczmik
 
Posts: 4
Joined: Tue Apr 26, 2016 3:20 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Wed May 04, 2016 9:45 pm

Also I don't think that you should sleep 5 seconds before taking any actions.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby windmaker » Wed May 04, 2016 11:31 pm

b0r3d0m wrote:Also I don't think that you should sleep 5 seconds before taking any actions.

the walking have some problems. so or make a sleep or make a finishFP function (or wathever what is)
Image #swag
User avatar
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

Postby b0r3d0m » Thu May 05, 2016 7:14 am

windmaker wrote:
b0r3d0m wrote:Also I don't think that you should sleep 5 seconds before taking any actions.

the walking have some problems. so or make a sleep or make a finishFP function (or wathever what is)

See the `waitForPf` function.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby Thedrah » Thu May 05, 2016 10:27 am

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 :P

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)


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?
  ▲
▲ ▲
Thedrah
 
Posts: 936
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

PreviousNext

Return to The Wizards' Tower

Who is online

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