summaryrefslogtreecommitdiff
path: root/src/emap/script_buildins.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-21 21:54:18 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-21 21:54:18 +0300
commit1af2a074bd643a5564a9911ee6cc9356673182be (patch)
tree4a7ecd8142bf1e2dba841cbb48d4f095d1c86be3 /src/emap/script_buildins.c
parent081236e0f54d19058b0fd26abd5c9499df91bbb7 (diff)
downloadplugin-1af2a074bd643a5564a9911ee6cc9356673182be.tar.gz
plugin-1af2a074bd643a5564a9911ee6cc9356673182be.tar.bz2
plugin-1af2a074bd643a5564a9911ee6cc9356673182be.tar.xz
plugin-1af2a074bd643a5564a9911ee6cc9356673182be.zip
Add script command for get card from item by inventory index.
New script command: getcardbyindex itemIndex, cardIndex
Diffstat (limited to 'src/emap/script_buildins.c')
-rw-r--r--src/emap/script_buildins.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 6a34298..7b5a224 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -1333,6 +1333,43 @@ BUILDIN(failedRemoveCardsIndex)
return true;
}
+BUILDIN(getCardByIndex)
+{
+ getSD()
+ getInventoryIndex(2)
+
+ if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0)
+ {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ const int c = script_getnum(st, 3);
+ if (c < 0 || c >= MAX_SLOTS)
+ {
+ script_pushint(st, 0);
+ return false;
+ }
+
+ if (itemdb_isspecial(sd->status.inventory[n].card[0]))
+ {
+ script_pushint(st, 0);
+ return true;
+ }
+
+ const int card = sd->status.inventory[n].card[c];
+ if (card && itemdb_type(card) == IT_CARD)
+ {
+ script_pushint(st, card);
+ }
+ else
+ {
+ script_pushint(st, 0);
+ }
+
+ return true;
+}
+
// return paramater type
// 0 - int
// 1 - string