Scrifen -- Hafen scripting API

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

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Sat Apr 30, 2016 10:26 pm

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

Postby b0r3d0m » Sat Apr 30, 2016 10:27 pm

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

Re: Scrifen -- Hafen scripting API

Postby Thedrah » Sat Apr 30, 2016 11:17 pm

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

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Sun May 01, 2016 7:17 am

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

Re: Scrifen -- Hafen scripting API

Postby lacucaracha » Mon May 02, 2016 3:40 am

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
lacucaracha
 
Posts: 171
Joined: Thu Dec 05, 2013 4:50 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Mon May 02, 2016 7:22 am

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

Postby b0r3d0m » Mon May 02, 2016 7:25 am

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

Postby b0r3d0m » Mon May 02, 2016 7:26 am

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

Re: Scrifen -- Hafen scripting API

Postby lacucaracha » Mon May 02, 2016 8:00 am

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

Postby lacucaracha » Mon May 02, 2016 8:12 am

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.
User avatar
lacucaracha
 
Posts: 171
Joined: Thu Dec 05, 2013 4:50 pm

PreviousNext

Return to The Wizards' Tower

Who is online

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