Yeah. All functions related to the game interface should be called via the game reference.Thedrah wrote:are you using "g.sendVillageChatMessage('test');"? i noticed a lot of functions don't work without the 'g.' part hehedzielny_wojownik wrote: btw, it shows that chat message functions are not defined for me when I'm trying to use themand yes, I have the newest client available from the post
sendVillageChatMessage('test');
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
You can use `onUserInput` API event at the moment and I will definitely think about adding some GUI elements later.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!
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
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
it is used by the amber auto survey bot to select stockpiles for dirt placement
▲
▲ ▲
▲ ▲
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Added, see `onMapObjectHighlight` API event and `getHighlightedMapObjects` API function.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
Please note that you should define the `onMapObjectHighlight` function starting from now even if you don't want to handle it.
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
How is onUserInput supposed to work?
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 onUserInput(input) {
if(input == "bots"){
print('Bots:\n chopper');
}else if(input == "chopper"){
startChopperBot();
}
}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.
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Added, see `waitForTaskToFinish` API function in the updated client.lacucaracha wrote:Add a "waitCurrent()" or similar, that waits the current action to finish.
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Are you sure that there should be whitespace character at the beginning of trees names like " conkertree", " rowan" and " whitebeam"?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 }
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Sounds strange. Do you receive any error output for such characters?lacucaracha wrote:I also think that the select character function isnt working if you char has ~ or ´ in his name.
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
No. It just says "Selection Character", but doesnt select it.b0r3d0m wrote:Sounds strange. Do you receive any error output for such characters?lacucaracha wrote:I also think that the select character function isnt working if you char has ~ or ´ in his name.
Nope, there should not! Thanks, heh.b0r3d0m wrote:Are you sure that there should be whitespace character at the beginning of trees names like " conkertree", " rowan" and " whitebeam"?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 }
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
Thanks! That will be really usefull.b0r3d0m wrote:Added, see `waitForTaskToFinish` API function in the updated client.lacucaracha wrote:Add a "waitCurrent()" or similar, that waits the current action to finish.