From d3648e1b1b87c0e130454b45c74c244bb21164ae Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 31 Jul 2020 22:20:21 -0300 Subject: @setvar and @getvar, similar style to TMWA This is to allow me to @set arrays, as it was not working well previously. ...I really could just reimplement @set, though... --- npc/commands/debug.txt | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file 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; } + -- cgit v1.2.3-60-g2f50