Is there a way to select an area, like in claims, paving and etc?
Also, is there any function that gives me the type of terrain i'm standing/is next to me?
@edit
I also miss a function to put a item from your hand on the inventory, and another one to pick dropped itens from the ground. Ty!
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
you can use the g.mapobjectarightclick(object.id); for picking up the item
found out when carrots growing use the same name as the dropped carrots
found out when carrots growing use the same name as the dropped carrots
▲
▲ ▲
▲ ▲
-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
Cool! Thanks!Thedrah wrote:you can use the g.mapobjectarightclick(object.id); for picking up the item
found out when carrots growing use the same name as the dropped carrots
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
warning to people making a carrot harvesting script: the create stockpile function will plant the carrot if it's over plowed land
▲
▲ ▲
▲ ▲
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Update is available.
Added new API methods:
Added new API methods:
- useItemFromHandOnCoords(x, y)
- dropItemFromHandToWindow(windowName)
- takeItemFromWindow(windowName, itemName)
- feastEat(itemName)
- openTable(id)
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
See the previous post.Thedrah wrote:is there a way to have the script use 'feast' at a table?
You can write code like this now:
Code: Select all
var thrones = g.getMapObjects('cottagethrone');
if (thrones != null && thrones.length > 0) {
var throne = thrones[0];
g.mapObjectRightClick(throne.id);
sleep(3000);
var tables = g.getMapObjects('cottagetable');
if (tables != null && tables.length > 0) {
var table = tables[0];
g.openTable(table.id);
sleep(3000);
g.feastEat('blueberry');
}
}Not at the moment.Thedrah wrote:edit: a way to get the stats of an animal? with name of stat with the number?
Ok, I'll add the corresponding function.Thedrah wrote:possible for a simple left click on a tile would solve most cases
It seems that you don't have `onMapObjectHighlight` function in your script.Thedrah wrote:can't use highlighted objects due to errorCode: Select all
java.lang.ClassCastException: org.mozilla.javascript.UniqueTag cannot be cast to org.mozilla.javascript.Function at haven.Evaluator.call(Evaluator.java:139) at haven.ChatUI$MultiChat.lambda$uimsg$0(ChatUI.java:805) at haven.Evaluator.lambda$new$0(Evaluator.java:39) at java.lang.Thread.run(Unknown Source)
Define it like this:
Code: Select all
/** It is fired when a new object highlighted via ALT + LMB
* @param {Object} obj Highlighted map object
* @param {String} obj.name Basename of the map object's resource
* @param {String} obj.fullName Full name of the map object's resource
* @param {Number} obj.id Map object's ID
* @param {Object} obj.coords Coordinates of the map object
* @param {Number} obj.coords.x x coordinate of the map object
* @param {Number} obj.coords.y y coordinate of the map object
*/
function onMapObjectHighlight(obj) {
// ignored
}Not at the moment, I'll add it.Thedrah wrote:is there a way to get an array of items in study?
I'm thinking about it from time to time. The problem is WItems / GItems have any ID related to them.Thedrah wrote:and any way to get the quality of an item?
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Not at the moment, will think about adding them.lacucaracha wrote:Is there a way to select an area, like in claims, paving and etc?
Also, is there any function that gives me the type of terrain i'm standing/is next to me?
You can use `dropItemFromHandToWindow` function from the last update.lacucaracha wrote:I also miss a function to put a item from your hand on the inventory
-
Thedrah
- Posts: 943
- Joined: Fri Apr 08, 2011 2:20 am
- Location: behind you
Re: Scrifen -- Hafen scripting API
you're amazing. currently attempting to add a script to automate walking around my base then to initiate other scripts/functions to make actions happen. then i can consider it a bot
i got a carrot and barley harvesting script, now to add planting. then other plants and possibly work orders. the onMapObjectSelect function makes things go much smoother/quicker. with the animal stats i can make a true farmhand. if we can get stats of an item from inventory/window i'll be able to do automated farming with inspecting
only things holding me up are; i can't seem to carry a barrel through mineholes/ladders or travel along a milestone using g.mapObjectRightClick(id). i have to use buckets atm, which i guess is just an efficiency problem.
and entering buildings seems to escape me, is there a certain name i'm missing? trying to enter a stonetower by g.mapObjectRightClick(g.getMapObjects('stonetower')[0].id); which gets a proper id but it appears not to be selecting the door
convenience features would be to have a way to get liters from a foodtrough. that way i could log consumption of animals
the coordinates seem to not be static so i've started to rely on objects as land markers, would it be possible to get either the res of a tile or what is on a display sign? such as to allow for a script to fill an area paved of schist with wood blocks
another feature i could think of would be to repair stuff such as walls, looms, or plows. maybe a function such as getObjectHealth
for a mining script i think i need a function for ondustfall(x, y) unless i plan on throwing tons of metal at it. and maybe res tiles of walls
after that a scout script would need to be able to determine res tiles on the ground to be able to traverse rivers imo.
any chance of getting combat functions? such as a current list of combat cards and ability to activate one. i should really read into how to compile a custom client haha just seems like a cluster fuck to get started
edit: i want to use a cart but i can only pull the cart with the script. could we get the parts of the object, maybe in array form? or something more simple? could possibly allow for a more efficient script for changing hides, knowing if leather is done by the water, and possibly entering houses. might allow for knowing if a cupboard has stuff in it or a table have symbel on it
edit 2: trying to make a script to grind barley flour, i can't seem to be able figure out how to get barley seed from a barrel or equip a bucket of seed from hand or a container. can't equip an item from hand or container. i can't seem to open a chest next to a quern either
still can make a grinding script but requires no barley seed in barrel/bucket
i got a carrot and barley harvesting script, now to add planting. then other plants and possibly work orders. the onMapObjectSelect function makes things go much smoother/quicker. with the animal stats i can make a true farmhand. if we can get stats of an item from inventory/window i'll be able to do automated farming with inspecting
only things holding me up are; i can't seem to carry a barrel through mineholes/ladders or travel along a milestone using g.mapObjectRightClick(id). i have to use buckets atm, which i guess is just an efficiency problem.
and entering buildings seems to escape me, is there a certain name i'm missing? trying to enter a stonetower by g.mapObjectRightClick(g.getMapObjects('stonetower')[0].id); which gets a proper id but it appears not to be selecting the door
convenience features would be to have a way to get liters from a foodtrough. that way i could log consumption of animals
the coordinates seem to not be static so i've started to rely on objects as land markers, would it be possible to get either the res of a tile or what is on a display sign? such as to allow for a script to fill an area paved of schist with wood blocks
another feature i could think of would be to repair stuff such as walls, looms, or plows. maybe a function such as getObjectHealth
for a mining script i think i need a function for ondustfall(x, y) unless i plan on throwing tons of metal at it. and maybe res tiles of walls
after that a scout script would need to be able to determine res tiles on the ground to be able to traverse rivers imo.
any chance of getting combat functions? such as a current list of combat cards and ability to activate one. i should really read into how to compile a custom client haha just seems like a cluster fuck to get started
edit: i want to use a cart but i can only pull the cart with the script. could we get the parts of the object, maybe in array form? or something more simple? could possibly allow for a more efficient script for changing hides, knowing if leather is done by the water, and possibly entering houses. might allow for knowing if a cupboard has stuff in it or a table have symbel on it
edit 2: trying to make a script to grind barley flour, i can't seem to be able figure out how to get barley seed from a barrel or equip a bucket of seed from hand or a container. can't equip an item from hand or container. i can't seem to open a chest next to a quern either
still can make a grinding script but requires no barley seed in barrel/bucket
▲
▲ ▲
▲ ▲
-
b0r3d0m
- Posts: 95
- Joined: Sun Sep 13, 2015 2:39 pm
Re: Scrifen -- Hafen scripting API
Update is available.
The long-awaited "disable rendering" feature finally implemented.
You should define new `onClientStarted` API hook in the following manner:
Note that you have to define it even if you don't want to disable rendering.
The long-awaited "disable rendering" feature finally implemented.
You should define new `onClientStarted` API hook in the following manner:
Code: Select all
/**
* It is fired when the client started
* @return {Object} options - Object that contains general options for the client
* @return {Boolean} options.renderingEnabled - Set this option to `false` if you want to disable rendering
*/
function onClientStarted() {
var options = {
renderingEnabled: true
};
return options;
}-
lacucaracha
- Posts: 171
- Joined: Thu Dec 05, 2013 4:50 pm
Re: Scrifen -- Hafen scripting API
Suggestion:
getInventorySize();
(maybe)
getInventoryEmptySlots();
getInventorySize();
(maybe)
getInventoryEmptySlots();