summaryrefslogtreecommitdiff
path: root/src/emap/script_buildins.c
diff options
context:
space:
mode:
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