summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-31 22:20:21 -0300
committerJesusaves <cpntb1@ymail.com>2020-07-31 22:20:21 -0300
commitd3648e1b1b87c0e130454b45c74c244bb21164ae (patch)
treeb7c4c575d63b02b4ce20191d8edb8f6b31bbaaf9
parent4137f460c9221ea861ad4111070a249d69860a2e (diff)
downloadserverdata-r12.4_20200801.tar.gz
serverdata-r12.4_20200801.tar.bz2
serverdata-r12.4_20200801.tar.xz
serverdata-r12.4_20200801.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.txt50
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;
}
+