diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-12 01:48:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-12 01:48:43 +0300 |
commit | 32edcdcf47c804d0bb40299fad5d184b558bb76c (patch) | |
tree | 279589abd15ec4d939cf251125ea29aee035596a /src/emap/script.c | |
parent | 0055aac688833a01cbe2b3e6b951bb162a80b474 (diff) | |
download | evol-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.c | 23 |
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; +} |