Scrifen -- Hafen scripting API

Forum for alternative clients, mods & discussions on the same.
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

Thedrah wrote:
dzielny_wojownik wrote: btw, it shows that chat message functions are not defined for me when I'm trying to use them :? and yes, I have the newest client available from the post
sendVillageChatMessage('test');
are you using "g.sendVillageChatMessage('test');"? i noticed a lot of functions don't work without the 'g.' part hehe
Yeah. All functions related to the game interface should be called via the game reference.
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

lacucaracha wrote:Your client is great, keep up the good work!
Just one thing, it would be way better if we could create several scripts and load/stop them ingame, like union client used to be!
Thanks!
You can use `onUserInput` API event at the moment and I will definitely think about adding some GUI elements later.
Thedrah
Posts: 943
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

Re: Scrifen -- Hafen scripting API

Post by Thedrah »

amber by default has a mapobject select thingy by alt-right click that makes the object glow red for a moment. is it possible to have a method to list or get the objects selected in such a manner?

it is used by the amber auto survey bot to select stockpiles for dirt placement
  ▲
▲ ▲
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

Thedrah wrote:amber by default has a mapobject select thingy by alt-right click that makes the object glow red for a moment. is it possible to have a method to list or get the objects selected in such a manner?

it is used by the amber auto survey bot to select stockpiles for dirt placement
Added, see `onMapObjectHighlight` API event and `getHighlightedMapObjects` API function.

Please note that you should define the `onMapObjectHighlight` function starting from now even if you don't want to handle it.
User avatar
lacucaracha
Posts: 171
Joined: Thu Dec 05, 2013 4:50 pm

Re: Scrifen -- Hafen scripting API

Post by lacucaracha »

How is onUserInput supposed to work?

Code: Select all

function onUserInput(input) {
	if(input == "bots"){
		print('Bots:\n chopper');  
	}else if(input == "chopper"){
		startChopperBot();
	}
}
I tried it like this, but when i type :bots or :chopper, nothing happens.

I also think that the select character function isnt working if your char has ~ or ´ in his name.

@edit
Ok, the input has to be on the cmd prompt. My bad.

@suggestion
Add a "waitCurrent()" or similar, that waits the current action to finish.

@code
Here is a function i made to check whether its a tree.

Code: Select all

function isTree(tree) {
  return tree == "alder" || tree == "appletree" || tree == "ash" || tree == "aspen" || tree == "baywillow" || tree == "beech" || tree == "birch" ||
  tree == "birdcherrytree" || tree == "buckthorn" || tree == "cedar" || tree == "cherry" || tree == "chestnuttree" || tree == " conkertree" || 
  tree == "corkoak" || tree == "crabappletree" || tree == "cypress" || tree == "elm" || tree == "fir" || tree == "goldenchain" || tree == "hazel" ||
  tree == "hornbeam" || tree == "juniper" || tree == "kingsoak" || tree == "larch" || tree == "laurel" || tree == "linden" || tree == "maple" ||
  tree == "mulberry" || tree == "oak" || tree == "olivetree" || tree == "peatree" || tree == "pine" || tree == "planetree" || tree == "plumtree" ||
  tree == "poplar" || tree == " rowan" || tree == "sallow" || tree == "spruce" || tree == "sweetgum" || tree == "walnuttree" || tree == " whitebeam" ||
  tree == "willow" || tree == "yew"; // etc
}
Last edited by lacucaracha on Mon May 02, 2016 8:14 am, edited 1 time in total.
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

lacucaracha wrote:Add a "waitCurrent()" or similar, that waits the current action to finish.
Added, see `waitForTaskToFinish` API function in the updated client.
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

lacucaracha wrote: Here is a function i made to check whether its a tree.

Code: Select all

function isTree(tree) {
  return tree == "alder" || tree == "appletree" || tree == "ash" || tree == "aspen" || tree == "baywillow" || tree == "beech" || tree == "birch" ||
  tree == "birdcherrytree" || tree == "buckthorn" || tree == "cedar" || tree == "cherry" || tree == "chestnuttree" || tree == " conkertree" || 
  tree == "corkoak" || tree == "crabappletree" || tree == "cypress" || tree == "elm" || tree == "fir" || tree == "goldenchain" || tree == "hazel" ||
  tree == "hornbeam" || tree == "juniper" || tree == "kingsoak" || tree == "larch" || tree == "laurel" || tree == "linden" || tree == "maple" ||
  tree == "mulberry" || tree == "oak" || tree == "olivetree" || tree == "peatree" || tree == "pine" || tree == "planetree" || tree == "plumtree" ||
  tree == "poplar" || tree == " rowan" || tree == "sallow" || tree == "spruce" || tree == "sweetgum" || tree == "walnuttree" || tree == " whitebeam" ||
  tree == "willow" || tree == "yew"; // etc
}
Are you sure that there should be whitespace character at the beginning of trees names like " conkertree", " rowan" and " whitebeam"?
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

lacucaracha wrote:I also think that the select character function isnt working if you char has ~ or ´ in his name.
Sounds strange. Do you receive any error output for such characters?
User avatar
lacucaracha
Posts: 171
Joined: Thu Dec 05, 2013 4:50 pm

Re: Scrifen -- Hafen scripting API

Post by lacucaracha »

b0r3d0m wrote:
lacucaracha wrote:I also think that the select character function isnt working if you char has ~ or ´ in his name.
Sounds strange. Do you receive any error output for such characters?
No. It just says "Selection Character", but doesnt select it.
b0r3d0m wrote:
lacucaracha wrote: Here is a function i made to check whether its a tree.

Code: Select all

function isTree(tree) {
  return tree == "alder" || tree == "appletree" || tree == "ash" || tree == "aspen" || tree == "baywillow" || tree == "beech" || tree == "birch" ||
  tree == "birdcherrytree" || tree == "buckthorn" || tree == "cedar" || tree == "cherry" || tree == "chestnuttree" || tree == " conkertree" || 
  tree == "corkoak" || tree == "crabappletree" || tree == "cypress" || tree == "elm" || tree == "fir" || tree == "goldenchain" || tree == "hazel" ||
  tree == "hornbeam" || tree == "juniper" || tree == "kingsoak" || tree == "larch" || tree == "laurel" || tree == "linden" || tree == "maple" ||
  tree == "mulberry" || tree == "oak" || tree == "olivetree" || tree == "peatree" || tree == "pine" || tree == "planetree" || tree == "plumtree" ||
  tree == "poplar" || tree == " rowan" || tree == "sallow" || tree == "spruce" || tree == "sweetgum" || tree == "walnuttree" || tree == " whitebeam" ||
  tree == "willow" || tree == "yew"; // etc
}
Are you sure that there should be whitespace character at the beginning of trees names like " conkertree", " rowan" and " whitebeam"?
Nope, there should not! Thanks, heh.
User avatar
lacucaracha
Posts: 171
Joined: Thu Dec 05, 2013 4:50 pm

Re: Scrifen -- Hafen scripting API

Post by lacucaracha »

b0r3d0m wrote:
lacucaracha wrote:Add a "waitCurrent()" or similar, that waits the current action to finish.
Added, see `waitForTaskToFinish` API function in the updated client.
Thanks! That will be really usefull.

Return to “The Wizards' Tower”