Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/assets/opensb/scripts
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2025-02-04 11:07:36 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2025-02-04 11:07:36 +1100
commitd7c08fb14425ba1ae3f74cc4c5133f95b27daaf0 (patch)
tree56f622c292be9c0f0637f65a64b2384f3e775e5d /assets/opensb/scripts
parent7c5042ec7bf693b06f7e9e150db7d2f9d05058f3 (diff)
polish identity command a bit
Diffstat (limited to 'assets/opensb/scripts')
-rw-r--r--assets/opensb/scripts/opensb/player/commands.lua3
-rw-r--r--assets/opensb/scripts/opensb/player/identity.lua46
2 files changed, 26 insertions, 23 deletions
diff --git a/assets/opensb/scripts/opensb/player/commands.lua b/assets/opensb/scripts/opensb/player/commands.lua
index 96f6e8c..2d83106 100644
--- a/assets/opensb/scripts/opensb/player/commands.lua
+++ b/assets/opensb/scripts/opensb/player/commands.lua
@@ -47,5 +47,4 @@ register("headrotation", function(arg)
end
end)
-module.register = register
-module.splitArgs = splitArgs \ No newline at end of file
+module.register = register \ No newline at end of file
diff --git a/assets/opensb/scripts/opensb/player/identity.lua b/assets/opensb/scripts/opensb/player/identity.lua
index d076910..c1f8a31 100644
--- a/assets/opensb/scripts/opensb/player/identity.lua
+++ b/assets/opensb/scripts/opensb/player/identity.lua
@@ -1,31 +1,35 @@
local module = {}
-modules.copy_paste = module
-
+modules.identity = module
local commands = modules.commands
-
commands.register("identity", function(args)
- method, path, value = chat.parseArguments(args)
+ local method, path, value = chat.parseArguments(args)
if not method or method == "get" or method == "" then
local identity = player.humanoidIdentity()
-
- if path then
- if identity[path] then
- return string.format(identity[path])
+ if path then
+ value = identity[path]
+ if value or path == "imagePath" then
+ return sb.printJson(value)
else
- return string.format("%s is not a part of the identity", path)
- end
- end
-
- return sb.printJson(player.humanoidIdentity(), 1)
- elseif method == "set" and path and value then
- local identity = player.humanoidIdentity()
- if not identity[path] then
- return string.format("%s is not a part of the identity", path)
- end
- identity[path] = value
- player.setHumanoidIdentity(identity)
- return string.format("Set %s to %s", path, value)
+ return string.format("%s is not a part of the identity", path)
+ end
+ end
+ return sb.printJson(player.humanoidIdentity(), 1)
+ elseif method == "set" and path then
+ local identity = player.humanoidIdentity()
+ local prev = identity[path]
+ if path ~= "imagePath" then
+ if not prev then
+ return string.format("%s is not a part of the identity", path)
+ elseif type(prev) ~= type(value) then
+ return string.format("%s must be a %s", path, type(prev))
+ end
+ elseif type(value) ~= "nil" and type(value) ~= "string" then
+ return "imagePath must be null or a string"
+ end
+ identity[path] = value
+ player.setHumanoidIdentity(identity)
+ return string.format("Set %s to %s", path, value)
else
return "Usage: /identity <get|set> [path] [value]"
end