summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/dev/test.txt6
-rw-r--r--src/map/script.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/npc/dev/test.txt b/npc/dev/test.txt
index bdbc52ed4..c2f07ab2f 100644
--- a/npc/dev/test.txt
+++ b/npc/dev/test.txt
@@ -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;
diff --git a/src/map/script.c b/src/map/script.c
index be608830f..421def5f9 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -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;