Scrifen -- Hafen scripting API

Forum for alternative clients, mods & discussions on the same.
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Scrifen -- Hafen scripting API

Post by b0r3d0m »

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
ydex
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Scrifen -- Hafen scripting API

Post by ydex »

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

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

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
ydex
Posts: 747
Joined: Mon Apr 11, 2011 4:08 pm

Re: Scrifen -- Hafen scripting API

Post by ydex »

Does it autopath when picking items with pickItems?
bold
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

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

Re: Scrifen -- Hafen scripting API

Post by ydex »

Awsome. You're awsome man :D
bold
Gloosx_inn
Posts: 32
Joined: Mon Jul 01, 2013 6:49 pm

Re: Scrifen -- Hafen scripting API

Post by Gloosx_inn »

Any JSDocs?
Small sturdy creature fond of drink and industry
User avatar
b0r3d0m
Posts: 95
Joined: Sun Sep 13, 2015 2:39 pm

Re: Scrifen -- Hafen scripting API

Post by b0r3d0m »

Gloosx_inn wrote:Any JSDocs?
Not at the moment. Will write them as soon as possible.
User avatar
Zeler
Posts: 1484
Joined: Thu Apr 14, 2011 2:09 pm

Re: Scrifen -- Hafen scripting API

Post by Zeler »

The robotlings rise again.
algorithm
Posts: 218
Joined: Thu Aug 13, 2015 2:17 pm

Re: Scrifen -- Hafen scripting API

Post by algorithm »

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. ;)

Return to “The Wizards' Tower”