diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-07-31 22:20:21 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-07-31 22:20:21 -0300 |
commit | d3648e1b1b87c0e130454b45c74c244bb21164ae (patch) | |
tree | b7c4c575d63b02b4ce20191d8edb8f6b31bbaaf9 | |
parent | 4137f460c9221ea861ad4111070a249d69860a2e (diff) | |
download | serverdata-d3648e1b1b87c0e130454b45c74c244bb21164ae.tar.gz serverdata-d3648e1b1b87c0e130454b45c74c244bb21164ae.tar.bz2 serverdata-d3648e1b1b87c0e130454b45c74c244bb21164ae.tar.xz serverdata-d3648e1b1b87c0e130454b45c74c244bb21164ae.zip |
@setvar and @getvar, similar style to TMWAr12.4_20200801
This is to allow me to @set arrays, as it was not working well previously.
...I really could just reimplement @set, though...
-rw-r--r-- | npc/commands/debug.txt | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/npc/commands/debug.txt b/npc/commands/debug.txt index 5d628eca3..58764aec9 100644 --- a/npc/commands/debug.txt +++ b/npc/commands/debug.txt @@ -71,11 +71,57 @@ OnCall: if (!is_admin()) { end; } - GlobalDebugMenu; + GlobalDebugMenu(); closedialog; end; +OnSetVar: + if (getarraysize(.@atcmd_parameters$) != 3) + Exception("Usage: @set-var VARIABLE INDEX VALUE", RB_DISPBOTTOM|RB_ISFATAL); + + .@cmd$=array_shift(.@atcmd_parameters$); + .@idx=atoi(array_shift(.@atcmd_parameters$)); + if (charat(.@atcmd_parameters$[0], + getstrlen(.@atcmd_parameters$[0])-1) == "$") + .@str=true; + + if (.@str) + .@val$=array_shift(.@atcmd_parameters$); + else + .@val=array_shift(.@atcmd_parameters$); + + if (.@str) + setd(sprintf("%s[%d]", .@cmd$, .@idx), .@val$); + else + setd(sprintf("%s[%d]", .@cmd$, .@idx), .@val); + + dispbottom sprintf("%s[%d] is now: %s", .@cmd$, .@idx, + getd(sprintf("%s[%d]", .@cmd$, .@idx))); + end; + +// If the char is not a staff member, it'll be sent to GM Log instead +OnGetVar: + if (getarraysize(.@atcmd_parameters$) != 2) + Exception("Usage: @get-var VARIABLE INDEX", RB_DISPBOTTOM|RB_ISFATAL); + + .@cmd$=array_shift(.@atcmd_parameters$); + .@idx=atoi(array_shift(.@atcmd_parameters$)); + + .@mg$=sprintf("%s[%d] == %s", .@cmd$, .@idx, + getd(sprintf("%s[%d]", .@cmd$, .@idx))); + + if (!is_staff()) + atcommand("@request System Information: "+.@mg$); + else + dispbottom(.@mg$); + end; + OnInit: bindatcmd "debug", "@debug::OnCall", 99, 99, 1; - // TODO / FIXME: add a @test command that opens the help window for test-server + bindatcmd "getvar", "@debug::OnGetVar", 99, 99, 1; + bindatcmd "get-var", "@debug::OnGetVar", 99, 99, 1; + bindatcmd "setvar", "@debug::OnSetVar", 99, 99, 1; + bindatcmd "set-var", "@debug::OnSetVar", 99, 99, 1; + end; } + |