summaryrefslogtreecommitdiff
path: root/src/map/magic-expr.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-02-24 22:06:23 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-03-15 09:47:46 -0700
commit42631b502b3446d71cfe2745045436d9497ee0ed (patch)
tree827b83a084be86604010425a38ba4cd4a9eea9a9 /src/map/magic-expr.cpp
parentcab317277a7adcdd5c44389b9e0deb521d56ca4b (diff)
downloadtmwa-42631b502b3446d71cfe2745045436d9497ee0ed.tar.gz
tmwa-42631b502b3446d71cfe2745045436d9497ee0ed.tar.bz2
tmwa-42631b502b3446d71cfe2745045436d9497ee0ed.tar.xz
tmwa-42631b502b3446d71cfe2745045436d9497ee0ed.zip
Allow any script variable to be accessed from magic (mostly)
Diffstat (limited to 'src/map/magic-expr.cpp')
-rw-r--r--src/map/magic-expr.cpp18
1 files changed, 17 insertions, 1 deletions
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<env_t>, val_t *result, const_array<val_t> args)
{
dumb_ptr<block_list> subject_p = ARGENTITY(0);
VarName var_name = stringish<VarName>(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<env_t>, val_t *result, const_array<val_t> args)
+{
+ dumb_ptr<block_list> subject_p = ARGENTITY(0);
+ VarName var_name = stringish<VarName>(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<ZString, fun_t> 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'),