|
@@ -25243,13 +25243,13 @@ BUILDIN_FUNC(achievement_condition){
|
|
|
/// Returns a reference to a variable of the specific instance ID.
|
|
|
/// Returns 0 if an error occurs.
|
|
|
///
|
|
|
-/// getvariableofinstance(<variable>, <instance ID>) -> <reference>
|
|
|
-BUILDIN_FUNC(getvariableofinstance)
|
|
|
+/// getinstancevar(<variable>, <instance ID>) -> <reference>
|
|
|
+BUILDIN_FUNC(getinstancevar)
|
|
|
{
|
|
|
struct script_data* data = script_getdata(st, 2);
|
|
|
|
|
|
if (!data_isreference(data)) {
|
|
|
- ShowError("buildin_getvariableofinstance: %s is not a variable.\n", script_getstr(st, 2));
|
|
|
+ ShowError("buildin_getinstancevar: %s is not a variable.\n", script_getstr(st, 2));
|
|
|
script_reportdata(data);
|
|
|
script_pushnil(st);
|
|
|
st->state = END;
|
|
@@ -25259,7 +25259,7 @@ BUILDIN_FUNC(getvariableofinstance)
|
|
|
const char* name = reference_getname(data);
|
|
|
|
|
|
if (*name != '\'') {
|
|
|
- ShowError("buildin_getvariableofinstance: Invalid scope. %s is not an instance variable.\n", name);
|
|
|
+ ShowError("buildin_getinstancevar: Invalid scope. %s is not an instance variable.\n", name);
|
|
|
script_reportdata(data);
|
|
|
script_pushnil(st);
|
|
|
st->state = END;
|
|
@@ -25269,7 +25269,7 @@ BUILDIN_FUNC(getvariableofinstance)
|
|
|
int instance_id = script_getnum(st, 3);
|
|
|
|
|
|
if (instance_id <= 0) {
|
|
|
- ShowError("buildin_getvariableofinstance: Invalid instance ID %d.\n", instance_id);
|
|
|
+ ShowError("buildin_getinstancevar: Invalid instance ID %d.\n", instance_id);
|
|
|
script_pushnil(st);
|
|
|
st->state = END;
|
|
|
return SCRIPT_CMD_FAILURE;
|
|
@@ -25278,7 +25278,7 @@ BUILDIN_FUNC(getvariableofinstance)
|
|
|
std::shared_ptr<s_instance_data> im = util::umap_find(instances, instance_id);
|
|
|
|
|
|
if (im->state != INSTANCE_BUSY) {
|
|
|
- ShowError("buildin_getvariableofinstance: Unknown instance ID %d.\n", instance_id);
|
|
|
+ ShowError("buildin_getinstancevar: Unknown instance ID %d.\n", instance_id);
|
|
|
script_pushnil(st);
|
|
|
st->state = END;
|
|
|
return SCRIPT_CMD_FAILURE;
|
|
@@ -25291,6 +25291,62 @@ BUILDIN_FUNC(getvariableofinstance)
|
|
|
return SCRIPT_CMD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
+/// Sets the value of an instance variable.
|
|
|
+///
|
|
|
+/// setinstancevar(<variable>,<value>,<instance ID>)
|
|
|
+BUILDIN_FUNC(setinstancevar)
|
|
|
+{
|
|
|
+ const char *command = script_getfuncname(st);
|
|
|
+ struct script_data* data = script_getdata(st, 2);
|
|
|
+
|
|
|
+ if (!data_isreference(data)) {
|
|
|
+ ShowError("buildin_%s: %s is not a variable.\n", command, script_getstr(st, 2));
|
|
|
+ script_reportdata(data);
|
|
|
+ script_pushnil(st);
|
|
|
+ st->state = END;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ const char* name = reference_getname(data);
|
|
|
+
|
|
|
+ if (*name != '\'') {
|
|
|
+ ShowError("buildin_%s: Invalid scope. %s is not an instance variable.\n", command, name);
|
|
|
+ script_reportdata(data);
|
|
|
+ script_pushnil(st);
|
|
|
+ st->state = END;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ int instance_id = script_getnum(st, 4);
|
|
|
+
|
|
|
+ if (instance_id <= 0) {
|
|
|
+ ShowError("buildin_%s: Invalid instance ID %d.\n", command, instance_id);
|
|
|
+ script_pushnil(st);
|
|
|
+ st->state = END;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::shared_ptr<s_instance_data> im = util::umap_find(instances, instance_id);
|
|
|
+
|
|
|
+ if (im->state != INSTANCE_BUSY) {
|
|
|
+ ShowError("buildin_%s: Unknown instance ID %d.\n", command, instance_id);
|
|
|
+ script_pushnil(st);
|
|
|
+ st->state = END;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ script_pushcopy(st, 2);
|
|
|
+
|
|
|
+ struct map_session_data* sd = nullptr;
|
|
|
+
|
|
|
+ if( is_string_variable(name) )
|
|
|
+ set_reg_str( st, sd, reference_getuid(data), name, script_getstr( st, 3 ), &im->regs );
|
|
|
+ else
|
|
|
+ set_reg_num( st, sd, reference_getuid(data), name, script_getnum64( st, 3 ), &im->regs );
|
|
|
+
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
convertpcinfo(<char_id>,<type>)
|
|
|
convertpcinfo(<account_id>,<type>)
|
|
@@ -26124,7 +26180,8 @@ struct script_function buildin_func[] = {
|
|
|
BUILDIN_DEF(camerainfo,"iii?"),
|
|
|
|
|
|
BUILDIN_DEF(achievement_condition,"i"),
|
|
|
- BUILDIN_DEF(getvariableofinstance,"ri"),
|
|
|
+ BUILDIN_DEF(getinstancevar,"ri"),
|
|
|
+ BUILDIN_DEF2_DEPRECATED(getinstancevar, "getvariableofinstance","ri", "2021-12-13"),
|
|
|
BUILDIN_DEF(convertpcinfo,"vi"),
|
|
|
BUILDIN_DEF(isnpccloaked, "??"),
|
|
|
|
|
@@ -26135,6 +26192,8 @@ struct script_function buildin_func[] = {
|
|
|
BUILDIN_DEF(getenchantgrade, ""),
|
|
|
|
|
|
BUILDIN_DEF(mob_setidleevent, "is"),
|
|
|
+
|
|
|
+ BUILDIN_DEF(setinstancevar,"rvi"),
|
|
|
#include "../custom/script_def.inc"
|
|
|
|
|
|
{NULL,NULL,NULL},
|