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-expr.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/map/magic-expr.cpp') diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index 7343e50..1628395 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -1006,11 +1006,26 @@ int fun_read_script_int(dumb_ptr, val_t *result, const_array args) { dumb_ptr subject_p = ARGENTITY(0); VarName var_name = stringish(ARGSTR(1)); + int array_index = 0; if (subject_p->bl_type != BL::PC) return 1; - RESULTINT = pc_readglobalreg(subject_p->is_player(), var_name); + RESULTINT = get_script_var_i(subject_p->is_player(), var_name, array_index); + return 0; +} + +static +int fun_read_script_str(dumb_ptr, val_t *result, const_array args) +{ + dumb_ptr subject_p = ARGENTITY(0); + VarName var_name = stringish(ARGSTR(1)); + int array_index = 0; + + if (subject_p->bl_type != BL::PC) + return 1; + + RESULTSTR = dumb_string::copys(get_script_var_s(subject_p->is_player(), var_name, array_index)); return 0; } @@ -1280,6 +1295,7 @@ std::map functions = MAGIC_FUNCTION1(anchor, "s", 'a'), MAGIC_FUNCTION("random_location", "a", 'l', fun_pick_location), MAGIC_FUNCTION("script_int", "es", 'i', fun_read_script_int), + MAGIC_FUNCTION("script_str", "es", 's', fun_read_script_str), MAGIC_FUNCTION1(rbox, "li", 'a'), MAGIC_FUNCTION1(count_item, "e.", 'i'), MAGIC_FUNCTION1(line_of_sight, "ll", 'i'), -- cgit v1.2.3-60-g2f50