From 42631b502b3446d71cfe2745045436d9497ee0ed Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 24 Feb 2014 22:06:23 -0800 Subject: Allow any script variable to be accessed from magic (mostly) --- src/map/magic-stmt.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/map/magic-stmt.cpp') diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp index 1905871..7ca718b 100644 --- a/src/map/magic-stmt.cpp +++ b/src/map/magic-stmt.cpp @@ -825,12 +825,28 @@ static int op_set_script_variable(dumb_ptr, const_array args) { dumb_ptr c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; + VarName varname = stringish(ARGSTR(1)); + int array_index = 0; if (!c) return 1; + set_script_var_i(c, varname, array_index, ARGINT(2)); + + return 0; +} + +static +int op_set_script_str(dumb_ptr, const_array args) +{ + dumb_ptr c = (ENTITY_TYPE(0) == BL::PC) ? ARGPC(0) : NULL; VarName varname = stringish(ARGSTR(1)); - pc_setglobalreg(c, varname, ARGINT(2)); + int array_index = 0; + + if (!c) + return 1; + + set_script_var_s(c, varname, array_index, ARGSTR(2)); return 0; } @@ -924,6 +940,7 @@ std::map operations = MAGIC_OPERATION1(injure, "eeii"), MAGIC_OPERATION1(emote, "ei"), MAGIC_OPERATION1(set_script_variable, "esi"), + MAGIC_OPERATION1(set_script_str, "ess"), MAGIC_OPERATION1(set_hair_colour, "ei"), MAGIC_OPERATION1(set_hair_style, "ei"), MAGIC_OPERATION("drop_item", "l.ii", op_drop_item_for), -- cgit v1.2.3-70-g09d2