aboutsummaryrefslogtreecommitdiff
path: root/src/methods/execute_squirrel.zig
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2024-05-05 16:51:48 +0200
committerJan200101 <sentrycraft123@gmail.com>2024-05-05 16:51:48 +0200
commit54365b02ef3e36a631354aa1af3bd33f90db3cf7 (patch)
treeb7f02a04c28437a1c44c427c440fe3f0750bed04 /src/methods/execute_squirrel.zig
downloadSouthRPC-54365b02ef3e36a631354aa1af3bd33f90db3cf7.tar.gz
SouthRPC-54365b02ef3e36a631354aa1af3bd33f90db3cf7.zip
Zig rework
Diffstat (limited to 'src/methods/execute_squirrel.zig')
-rw-r--r--src/methods/execute_squirrel.zig42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/methods/execute_squirrel.zig b/src/methods/execute_squirrel.zig
new file mode 100644
index 0000000..91a975f
--- /dev/null
+++ b/src/methods/execute_squirrel.zig
@@ -0,0 +1,42 @@
+const std = @import("std");
+
+const squirrel = @import("../squirrel.zig");
+
+const Allocator = std.mem.Allocator;
+
+pub const method = .{
+ .name = "execute_squirrel",
+ .func = execute_squirrel,
+};
+
+fn execute_squirrel(allocator: Allocator, params: ?std.json.Value) !?std.json.Value {
+ if (params == null or params.? != .object) {
+ return error.InvalidParameters;
+ }
+
+ const object = params.?.object;
+
+ const context = blk: {
+ const context_object = object.get("context");
+ if (context_object != null and context_object.? == .string) {
+ const context_string = context_object.?.string;
+
+ if (std.mem.eql(u8, context_string, "server")) {
+ break :blk squirrel.ScriptContext.SC_SERVER;
+ } else if (std.mem.eql(u8, context_string, "client")) {
+ break :blk squirrel.ScriptContext.SC_CLIENT;
+ } else if (std.mem.eql(u8, context_string, "ui")) {
+ break :blk squirrel.ScriptContext.SC_UI;
+ }
+
+ return error.InvalidContext;
+ }
+
+ break :blk squirrel.ScriptContext.SC_UI;
+ };
+ _ = context;
+
+ return .{
+ .string = "test",
+ };
+}