summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-04-13 21:10:33 -0500
committerWushin <pasekei@gmail.com>2015-04-13 21:10:33 -0500
commit9b5e4a69abecec73c71266de8ee8feb79842aea7 (patch)
treef36ff565fdfa58a4533c6da3b5a7e2bca279b8ad /src
parent3e589cd6fc0ef3a3958d1ace8f970c91e96b4b3d (diff)
parent11665e658145e02b4a77e90773eb6c19aa504a82 (diff)
downloadtmwa-9b5e4a69abecec73c71266de8ee8feb79842aea7.tar.gz
tmwa-9b5e4a69abecec73c71266de8ee8feb79842aea7.tar.bz2
tmwa-9b5e4a69abecec73c71266de8ee8feb79842aea7.tar.xz
tmwa-9b5e4a69abecec73c71266de8ee8feb79842aea7.zip
Merge pull request #27 from wushin/get-item-id
Script Builtin getitemlink
Diffstat (limited to 'src')
-rw-r--r--src/map/script-fun.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 5f530cb..6c04616 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2311,6 +2311,31 @@ void builtin_getitemname(ScriptState *st)
}
static
+void builtin_getitemlink(ScriptState *st)
+{
+ struct script_data *data;
+ AString buf;
+ data = &AARG(0);
+ ZString name = conv_str(st, data);
+
+ ItemNameId item_id;
+ Option<P<struct item_data>> item_data_ = itemdb_searchname(name);
+ OMATCH_BEGIN (item_data_)
+ {
+ OMATCH_CASE_SOME (item_data)
+ {
+ buf = STRPRINTF("[@@%d|%s@@]"_fmt, item_data->nameid, item_data->jname);
+ }
+ OMATCH_CASE_NONE ()
+ {
+ buf = STRPRINTF("Unknown Item: %s"_fmt, name);
+ }
+ }
+ OMATCH_END ();
+ push_str<ScriptDataStr>(st->stack, buf);
+}
+
+static
void builtin_getspellinvocation(ScriptState *st)
{
RString name = conv_str(st, &AARG(0));
@@ -3085,6 +3110,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(marriage, "P"_s, 'i'),
BUILTIN(divorce, ""_s, 'i'),
BUILTIN(getitemname, "I"_s, 's'),
+ BUILTIN(getitemlink, "I"_s, 's'),
BUILTIN(getspellinvocation, "s"_s, 's'),
BUILTIN(getpartnerid2, ""_s, 'i'),
BUILTIN(getinventorylist, ""_s, '\0'),