Scrifen -- Hafen scripting API

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

Scrifen -- Hafen scripting API

Postby b0r3d0m » Mon Apr 18, 2016 9:01 am

Sup guys.

For those of you who wants to write scripts for tasks automatization w/o recompiling or wants to have a simple way to write scripts (even if you don't know much about programming at all), I'd like to present the modified Amber client with JS scripting API.

All you need to do is download the client (or build it from sources if you wish) and place the script named "script.js" inside the root directory of the client's folder.

How does it look like?

To get the idea, you can take a look at the example script in my Scrifen repository on GitHub.

As you see, the client calls functions in your script when certain events occurs (including but not limited to `onLogin`, `onCharSelect`, `onGameLoaded`, `onCurioFound` etc).
You can also communicate with the client via the `game` object passed to the `onGameLoaded` hook (including but not limited to `studyCurio`, `getInvItems`, `goTo`, `transferItemsFrom`, `drink` etc).

How much this API can do?

Again, take a look at the example here. There are a lot of comments, incl. documentation (you can also view the generated JSDocs at http://80.220.243.128/Scrifen-JSDocs/ -- thanks to shubla).

For example, you can write a forager bot, drying frames / tanning tubs checker bot etc.

I need to do XXX, please add YYY function to your API

Feel free to write me about any ideas you have (either in this thread or PM).

There are a lot of custom solutions like this. My village has one, for example

Yep, I know. However, my solution is free, open-source, scriptable (you don't have to recompile the client to make a new script work) and easy-modifiable even for those who doesn't know much about programming and client's source code.
Moreover, what's wrong with having an additional option?

Client download link
Client's source code is available here ("feature/script-api" branch)
Last edited by b0r3d0m on Tue Jun 07, 2016 6:42 am, edited 2 times in total.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby ydex » Mon Apr 18, 2016 9:46 pm

if i change the nme Dandelion to, let's say, Blueberrie. Will it be able to pick blueberries or does it have to be curios?
bold
User avatar
ydex
 
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Mon Apr 18, 2016 9:52 pm

ydex wrote:Will it be able to pick blueberries

The `pickItem` function works for any pickable game object.

However, you will not receive any notification about blueberries because the `onCurioFound` hook triggers for curios only. I will think about adding the correspoding event type then.

For now, you can check such items via the `getMapObjects` function.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby ydex » Mon Apr 18, 2016 10:26 pm

Does it autopath when picking items with pickItems?
bold
User avatar
ydex
 
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Mon Apr 18, 2016 10:32 pm

ydex wrote:Does it autopath when picking items with pickItems?

Yep.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby ydex » Tue Apr 19, 2016 5:09 am

Awsome. You're awsome man :D
bold
User avatar
ydex
 
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Scrifen -- Hafen scripting API

Postby Gloosx_inn » Tue Apr 19, 2016 9:45 am

Any JSDocs?
Small sturdy creature fond of drink and industry
Gloosx_inn
 
Posts: 32
Joined: Mon Jul 01, 2013 6:49 pm

Re: Scrifen -- Hafen scripting API

Postby b0r3d0m » Tue Apr 19, 2016 9:57 am

Gloosx_inn wrote:Any JSDocs?

Not at the moment. Will write them as soon as possible.
User avatar
b0r3d0m
 
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Postby Zeler » Tue Apr 19, 2016 10:50 am

The robotlings rise again.
User avatar
Zeler
 
Posts: 1484
Joined: Thu Apr 14, 2011 2:09 pm

Re: Scrifen -- Hafen scripting API

Postby algorithm » Tue Apr 19, 2016 12:19 pm

How to read console input? for ex to stop script processing and run it again after a while?
algorithm wrote:Cape awarded? ;)

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

Next

Return to The Wizards' Tower

Who is online

Users browsing this forum: No registered users and 87 guests