summaryrefslogtreecommitdiff
path: root/src/emap/script.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-12 01:48:43 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-12 01:48:43 +0300
commit32edcdcf47c804d0bb40299fad5d184b558bb76c (patch)
tree279589abd15ec4d939cf251125ea29aee035596a /src/emap/script.c
parent0055aac688833a01cbe2b3e6b951bb162a80b474 (diff)
downloadevol-hercules-32edcdcf47c804d0bb40299fad5d184b558bb76c.tar.gz
evol-hercules-32edcdcf47c804d0bb40299fad5d184b558bb76c.tar.bz2
evol-hercules-32edcdcf47c804d0bb40299fad5d184b558bb76c.tar.xz
evol-hercules-32edcdcf47c804d0bb40299fad5d184b558bb76c.zip
Add script command for get item id from one craft slot.
New script command: getcraftslotid id, slot
Diffstat (limited to 'src/emap/script.c')
-rw-r--r--src/emap/script.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/emap/script.c b/src/emap/script.c
index 6cf911c..07950ab 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -1895,3 +1895,26 @@ BUILDIN(deleteCraft)
craft_delete(script_getnum(st, 2));
return true;
}
+
+BUILDIN(getCraftSlotId)
+{
+ getSD()
+
+ const struct craft_slot *crslot = craft_get_slot(script_getnum(st, 2),
+ script_getnum(st, 3));
+ if (!crslot)
+ return false;
+ const int len = VECTOR_LENGTH(crslot->items);
+ if (len > 0)
+ {
+ struct item_pair *pair = &VECTOR_INDEX(crslot->items, 0);
+ const int invIndex = pair->index;
+ const int item_id = sd->status.inventory[invIndex].nameid;
+ script_pushint(st, item_id);
+ }
+ else
+ {
+ script_pushint(st, 0);
+ }
+ return true;
+}