Prime - Amber Tweaks and Scripting API

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

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Sat Mar 11, 2017 8:50 pm

Thedrah wrote:request for a method to get the tile resource such as getTile(x,y); would return the tile resource name such as beechgrove or grass, mainly for water and cave navigation


I'm slowly developing a list, since the game returns numbers I have to manually convert the list to words, so for now you'll have to do some testing and debugging to do it manually. I am working on it.

kapytanhook wrote:Hey guys, working with prime here, long ago the api had "dropHandItem" how do you do this now?
I don't have the old api anymore and can't find how to drop what is in my hand on the floor.
Thanks :)

(found an answer to my own question, it may help someone else.)
var invItem = new Prime.__ItemObject(Prime.__GameUI.vhand); // get item in hand
invItem.Object.item.wdgmsg("drop", Packages.haven.Coord.z); // plot item in hand on ground


Code: Select all
drop("IF item is in your hand, this string can be anything I usually use the word of what Im expecting for simplicity");
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Sat Mar 11, 2017 9:09 pm

Small Devlog Update
Conversion to V8
The conversion to google V8 is making a lot of progress, we can now run the code pretty well.

Currently though I need to go through develop a way to give V8 access to the game, Mozilla Rhino had built in access but they did this as part of the parsing step, and since Its pretty stupid to
parse -> convert -> parse -> run


My plan is to scan the code for "Java." and attempt to find classes and packages following that keyword.

So to make a new java string you would do:
Code: Select all
var test = new Java.Java.lang.String


or a new Widget
Code: Select all
var test = new Java.Haven.Widget


While this does make Java.lang calls a bit longer, it does reduce the amount of steps my pre-parsing stage has to do, so that Prime doesnt slow down V8 by holding onto your script for too long

PrimeAPI 2.0
PrimeAPI is undergoing a massive overhaul. A lot of confusion on how things work, is mainly due to the major inconsistencies in how Prime handles the player versus objects for example. The API is being split into objects, as it should have been the moment we switched to JavaScript.

for example:
Code: Select all
getCoords();

Returns the players coords, but in the other areas of the API we have to get the object or Item and use the Coords field as part of that object. So we now have everything under specific objects.
Code: Select all
player.coords;
item.coords;
object.coords;
tile.coords;


it becomes very clear what the returned coords are for. it becomes very obvious what everything is suppose to be doing.


I have also re-wrote a lot of API interactions. We now longer have isIntersecting(Tile, Tile); Inventory tiles now have a built in function where they compare themselves to a given Tile, this reduces the amount of global functions, and allows you to have your own isIntersect function outside of the inventory slot object.


In otherwords, Prime is going to be a whole new version, as such it will require some script re-working. I will however be adding more functions such as the new equiptment object that allows you to list, unequipt and equip items. We are also going to be given the ability to disable rendering, a long requested feature. This feature may not be released until 2.1 however as I still want to give script writers the ability to present you with a Interface, and feedback so I may create some kind of manager that allows you to launch bots and users from a console/launcher specifically designed for nonrendered botting. I debated this for a long time, and may simply not remove rendering. Your thoughts on this are very appreciated.

Finally,
PathFinding Update:
While the amber Pathfinding has not been updated to include some many bugfixes, (and I can't be bothered to figure out what is going on in the pathfinding code amber is using) I am working on a JavaScript API pathfinder. One that will scan your area, and attempt to move around ridges. I may attempt to look for ridges that the player can climb as well, but for an imediate fix you can expect the new pathfinder when it launches to have some kind of understanding that ridges exist. So if you have a base like mine, you can expect that tree above your cave, not be harvestable without lots of confusing run around code
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby APXEOLOG » Sat Mar 11, 2017 11:22 pm

May i ask you a quesiton, why do you use Rhino/V8?
W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
User avatar
APXEOLOG
 
Posts: 1267
Joined: Fri Apr 23, 2010 7:58 am
Location: Somewhere on Earth

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Sun Mar 12, 2017 3:35 am

APXEOLOG wrote:May i ask you a quesiton, why do you use Rhino/V8?


I chose it mostly because it's easy to learn, fast and doesn't require me to build in a custom parser. I thought about going with other Java based scripting languages but I haven't had the time to test their speed and V8s offered a speed increase that doesn't really require me to switch.

Do you have an opinion on it versus a Java specific scripting language?
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby APXEOLOG » Sun Mar 12, 2017 10:02 am

Paradoxs wrote:Do you have an opinion on it versus a Java specific scripting language?

Well, since Java 8, there is built-in javascript engine called Nashorn

Pros:
  • It is a part of the jre, you don't need additional 3rd-party dependencies
  • It is the fastest possible implementation, because it actually compiles JS into the native Java bytecode one-the-fly
  • You don't need to bother about bindings, all java code is easy to invoke
  • It is very easy to setup and understand
Cons:
  • It doesn't support ES2015 features, but, iirc, the are planned for java 9 release
I use it for years already and i am pretty happy with it
W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
User avatar
APXEOLOG
 
Posts: 1267
Joined: Fri Apr 23, 2010 7:58 am
Location: Somewhere on Earth

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Sun Mar 12, 2017 10:55 am

APXEOLOG wrote:
Paradoxs wrote:Do you have an opinion on it versus a Java specific scripting language?

Well, since Java 8, there is built-in javascript engine called Nashorn

Pros:
  • It is a part of the jre, you don't need additional 3rd-party dependencies
  • It is the fastest possible implementation, because it actually compiles JS into the native Java bytecode one-the-fly
  • You don't need to bother about bindings, all java code is easy to invoke
  • It is very easy to setup and understand
Cons:
  • It doesn't support ES2015 features, but, iirc, the are planned for java 9 release
I use it for years already and i am pretty happy with it



V8 is actually faster when not being used to call one function one time. So for botting it's a lot better.

While nashorn was something I considered I chose V8 simply because of that speed bonus
In complex code or typescript the speed difference can even go into the values of 10x faster. (4 seconds versus 400 milliseconds)

The api shouldn't benefit a crazy amount from nashorn to V8 but if someone does run a script that goes for days and manages multiple tasks, in the long run V8 should be faster. When I'm done, I'll run my own metrics using API related code. If nashorn is indeed faster at its current stage I'll go ahead and switch the API over to it.

Half of the reason I'll be using it is because once I give it access to Java. I can reuse it in my own projects very freely as the current fastest implementation
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby APXEOLOG » Sun Mar 12, 2017 2:36 pm

Paradoxs wrote:if someone does run a script that goes for days and manages multiple tasks

Well, that's exactly what i do and i don't have any problems with Nashorn. But honestly i never had problems with js engine speed, even at the Rhino/Union times
W10 Meme Plot | W9 Mantis Garden | W8 Core | W7 Ofir | W6 the City of Dis | W5 Vitterstad | W4 A.D. | W3 Mirniy
jorb wrote:All your characters will be deleted, and I will level every village any one of them were ever members of.
User avatar
APXEOLOG
 
Posts: 1267
Joined: Fri Apr 23, 2010 7:58 am
Location: Somewhere on Earth

Re: Prime - Amber Tweaks and Scripting API

Postby Paradoxs » Sun Mar 12, 2017 7:13 pm

APXEOLOG wrote:
Paradoxs wrote:if someone does run a script that goes for days and manages multiple tasks

Well, that's exactly what i do and i don't have any problems with Nashorn. But honestly i never had problems with js engine speed, even at the Rhino/Union times


Oh I agree, I just figured I'd move to something that's being maintained so that script users can utilize new features and node.js
User avatar
Paradoxs
 
Posts: 294
Joined: Tue Aug 25, 2015 7:16 am

Re: Prime - Amber Tweaks and Scripting API

Postby tirioll » Tue Mar 21, 2017 6:11 pm

Please update :)
Code: Select all
0.3:null

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.String
   at haven.CharWnd$Quest$Box.uimsg(Unknown Source)
   at haven.CharWnd$Quest$DefaultBox.uimsg(Unknown Source)
   at NumenQuest.uimsg(ancquest.cjava:30)
   at haven.UI.uimsg(Unknown Source)
   at haven.RemoteUI.run(Unknown Source)
   at haven.MainFrame.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Also "Prime.WithScripts.rar" in release 1.1.1 does not start, seems that a bunch of files are missing. Is it supposed to be extracted on top of "Prime.rar" contents?
User avatar
tirioll
 
Posts: 144
Joined: Thu Nov 21, 2013 4:05 pm

Re: Prime - Amber Tweaks and Scripting API

Postby LostJustice » Tue Mar 21, 2017 9:05 pm

tirioll wrote:Please update :)
Code: Select all
0.3:null

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.String
   at haven.CharWnd$Quest$Box.uimsg(Unknown Source)
   at haven.CharWnd$Quest$DefaultBox.uimsg(Unknown Source)
   at NumenQuest.uimsg(ancquest.cjava:30)
   at haven.UI.uimsg(Unknown Source)
   at haven.RemoteUI.run(Unknown Source)
   at haven.MainFrame.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Also "Prime.WithScripts.rar" in release 1.1.1 does not start, seems that a bunch of files are missing. Is it supposed to be extracted on top of "Prime.rar" contents?


I noticed this too. I think the rar was packaged wrong. Use the zip.
Image
User avatar
LostJustice
 
Posts: 677
Joined: Sun Mar 25, 2012 3:57 am

PreviousNext

Return to The Wizards' Tower

Who is online

Users browsing this forum: Branden6474 and 4 guests