am i the only one having trouble with the method/function "onFlowerMenuOpen(options)"? i am trying to get it to work with "return options[0];" which doesn't do anything
i know it's being called as i have some print out in the command line but nothing is happening in game. even have the character wait 5+seconds before using return ._.
windows 7 64bit, 4gb, i3 cpu
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
-
algorithm
- Posts: 218
- Joined: Thu Aug 13, 2015 2:17 pm
Re: Scrifen -- Hafen scripting API
After few changes in onFlowerMenuOpen(options) you should call g.chooseFlowerMenuOption(option) instead of returning value.Thedrah wrote:am i the only one having trouble with the method/function "onFlowerMenuOpen(options)"? i am trying to get it to work with "return options[0];" which doesn't do anything
i know it's being called as i have some print out in the command line but nothing is happening in game. even have the character wait 5+seconds before using return ._.
windows 7 64bit, 4gb, i3 cpu
algorithm wrote:Cape awarded?
jorb wrote:Oh, for sure. Delivery 2022.
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Yep, what algorithm said.Thedrah wrote:am i the only one having trouble with the method/function "onFlowerMenuOpen(options)"? i am trying to get it to work with "return options[0];" which doesn't do anything
i know it's being called as i have some print out in the command line but nothing is happening in game. even have the character wait 5+seconds before using return ._.
windows 7 64bit, 4gb, i3 cpu
If it doesn't help you for some reason, feel free to post here your code so I can help you.
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
it worked, thanks guys
now to figure out how to make the guy pick the closest tree to chop
now to figure out how to make the guy pick the closest tree to chop
▲
▲ ▲
▲ ▲
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
You can use combination of getPlayerCoords and getAllMapObjects functions like this:Thedrah wrote:it worked, thanks guys
now to figure out how to make the guy pick the closest tree to chop
Code: Select all
function getDistance(lhs, rhs) {
var dx = lhs.x - rhs.x;
var dy = lhs.y - rhs.y;
return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
}
function getNearestMapObject() {
var nearestMapObject = null;
var playerCoords = g.getPlayerCoords();
var nearestMapObjectDistance = null;
var mapObjects = g.getAllMapObjects();
for (var i = 0; i < mapObjects.length; ++i) {
var mapObject = mapObjects[i];
if (mapObject.name == 'body') {
continue;
}
// TODO: Determine whether it is a tree
var distance = getDistance(playerCoords, mapObject.coords);
if (nearestMapObject == null || distance < nearestMapObjectDistance) {
nearestMapObject = mapObject;
nearestMapObjectDistance = distance;
}
}
return nearestMapObject;
}-
foomanchu
- Posts: 121
- Joined: Wed Jun 29, 2011 6:13 am
Re: Scrifen -- Hafen scripting API
any chance you can make it so theres a menu option (like amber's extensions) that has icons for multiple scripts? (similar to old haven clients that had scripting functionality)
not a particular fan of having only 1 script that runs when the client opens.. in legacy i must have had a few dozen scripts at least
but otherwise, great work.. i tried it out last night and its nice.. but its still missing some features for user qol.. start/stop script.. multiscript functionality.. and some api (that probably will get added in eventually).. but otherwise, good work!
not a particular fan of having only 1 script that runs when the client opens.. in legacy i must have had a few dozen scripts at least
but otherwise, great work.. i tried it out last night and its nice.. but its still missing some features for user qol.. start/stop script.. multiscript functionality.. and some api (that probably will get added in eventually).. but otherwise, good work!
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
You can load additional script files via `eval` function and you can use the `onUserInput` API event to launch different actions. I know that it doesn't what you actually want (there's no GUI-related stuff right now) but at least i worksfoomanchu wrote:any chance you can make it so theres a menu option (like amber's extensions) that has icons for multiple scripts? (similar to old haven clients that had scripting functionality)
not a particular fan of having only 1 script that runs when the client opens.. in legacy i must have had a few dozen scripts at least
but otherwise, great work.. i tried it out last night and its nice.. but its still missing some features for user qol.. start/stop script.. multiscript functionality.. and some api (that probably will get added in eventually).. but otherwise, good work!
-
dzielny_wojownik
- Posts: 703
- Joined: Thu Oct 02, 2014 10:38 am
- Location: Trapped in the autism cage with William
Re: Scrifen -- Hafen scripting API
great job, would love GUI also.
is there any way to find out if the autowalker/pathfinder is stuck on water or whatever, because it does get stuck when it tries to pathfind on water.
or on any other random stops
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');
is there any way to find out if the autowalker/pathfinder is stuck on water or whatever, because it does get stuck when it tries to pathfind on water.
or on any other random stops
btw, it shows that chat message functions are not defined for me when I'm trying to use them
sendVillageChatMessage('test');
There was a wise soviet conscript that was surrounded by the enemy on the battle of Stalingrad. A mortar shot teared his pants apart causing a big hole in his pants right on his right butt cheek. He felt a glorious cold ass breeze of wind on his butt cheek, like it would be sent by stalin himself, he said - hide your butts
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
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');
▲
▲ ▲
▲ ▲
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
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!
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!