Scrifen -- Hafen scripting API

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

Re: Scrifen -- Hafen scripting API

Postby Thedrah » Sat Apr 30, 2016 6:51 am

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

Re: Scrifen -- Hafen scripting API

Postby algorithm » Sat Apr 30, 2016 7:13 am

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


After few changes in onFlowerMenuOpen(options) you should call g.chooseFlowerMenuOption(option) instead of returning value.
algorithm wrote:Cape awarded? ;)

jorb wrote:Oh, for sure. Delivery 2022. ;)
algorithm
 
Posts: 216
Joined: Thu Aug 13, 2015 2:17 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Sat Apr 30, 2016 9:11 am

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

Yep, what algorithm said.

If it doesn't help you for some reason, feel free to post here your code so I can help you.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby Thedrah » Sat Apr 30, 2016 10:54 am

it worked, thanks guys

now to figure out how to make the guy pick the closest tree to chop
  ▲
▲ ▲
Thedrah
 
Posts: 936
Joined: Fri Apr 08, 2011 2:20 am
Location: behind you

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Sat Apr 30, 2016 12:19 pm

Thedrah wrote:it worked, thanks guys

now to figure out how to make the guy pick the closest tree to chop

You can use combination of getPlayerCoords and getAllMapObjects functions like this:

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

Re: Scrifen -- Hafen scripting API

Postby foomanchu » Sat Apr 30, 2016 5:52 pm

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!
foomanchu
 
Posts: 121
Joined: Wed Jun 29, 2011 6:13 am

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Sat Apr 30, 2016 6:33 pm

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

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

Re: Scrifen -- Hafen scripting API

Postby dzielny_wojownik » Sat Apr 30, 2016 7:18 pm

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');
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
User avatar
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

Postby Thedrah » Sat Apr 30, 2016 9:28 pm

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

Re: Scrifen -- Hafen scripting API

Postby lacucaracha » Sat Apr 30, 2016 9:40 pm

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!
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 90 guests