Permalink
Browse files

Merge pull request #2240 from Helianthella/getd-const

allow buildin_getd to work with constants and params
  • Loading branch information...
MishimaHaruna committed Oct 7, 2018
2 parents c0543f2 + 55f6666 commit 71205691cb441e398355944cdad992b6b60053ba
Showing with 9 additions and 1 deletion.
  1. +6 −0 npc/dev/test.txt
  2. +3 −1 src/map/script.c
View
@@ -651,6 +651,12 @@ function script HerculesSelfTestHelper {
setd(".@x", getd(".@y"));
callsub(OnCheck, "setd getd", .@x, .@y);
// getd types
callsub(OnCheck, "Getdatatype (getd: param)", getdatatype(getd("Hp")), DATATYPE_INT | DATATYPE_PARAM);
callsub(OnCheck, "Getdatatype (getd: const)", getdatatype(getd("DATATYPE_CONST")), DATATYPE_INT | DATATYPE_CONST);
callsub(OnCheck, "Getdatatype (getd: numeric var)", getdatatype(getd(".@foo")), DATATYPE_INT | DATATYPE_VAR);
callsub(OnCheck, "Getdatatype (getd: string var)", getdatatype(getd(".@foo$")), DATATYPE_STR | DATATYPE_VAR);
// getvariableofnpc
.x = 2;
set getvariableofnpc(.x, "TestVarOfAnotherNPC"), 1;
View
@@ -17847,7 +17847,9 @@ static BUILDIN(getd)
id = script->add_variable(varname);
if (script->str_data[id].type != C_NAME) {
if (script->str_data[id].type != C_NAME && // variable
script->str_data[id].type != C_PARAM && // param
script->str_data[id].type != C_INT) { // constant
ShowError("script:getd: `%s` is already used by something that is not a variable.\n", varname);
st->state = END;
return false;

0 comments on commit 7120569

Please sign in to comment.