Scrifen -- Hafen scripting API

Forum for alternative clients, mods & discussions on the same.
Thedrah
Posts: 943
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

Re: Scrifen -- Hafen scripting API

Post by Thedrah »

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 ^^
  ▲
▲ ▲
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

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

Post by b0r3d0m »

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
Kuczmik
Posts: 4
Joined: Tue Apr 26, 2016 3:20 pm

Re: Scrifen -- Hafen scripting API

Post by Kuczmik »

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

Post by windmaker »

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
Kuczmik
Posts: 4
Joined: Tue Apr 26, 2016 3:20 pm

Re: Scrifen -- Hafen scripting API

Post by Kuczmik »

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
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

Also I don't think that you should sleep 5 seconds before taking any actions.
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

Post by windmaker »

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
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

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

Re: Scrifen -- Hafen scripting API

Post by Thedrah »

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?
  ▲
▲ ▲

Return to “The Wizards' Tower”