Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Update script.lua
Browse files Browse the repository at this point in the history
- Remove `?tps` default permission for Everyone, give access to Auth

- Add `DEBUG` flag for debug logging
  • Loading branch information
carsakiller committed Mar 17, 2022
1 parent 738d324 commit 036ce5f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
local OWNER_STEAM_ID = "0"


local DEBUG = false

local ScriptVersion = "2.0.0"
local SaveDataVersion = "2.0.0"

Expand Down Expand Up @@ -1486,7 +1488,8 @@ local DEFAULT_ROLES = {
},
Auth = {
commands = {
setEditable = true
setEditable = true,
tpv = true,
},
active = true,
admin = false,
Expand All @@ -1511,7 +1514,6 @@ local DEFAULT_ROLES = {
tpc = true,
tpl = true,
tpp = true,
tpv = true,
tps = true,
tp2v = true,
transferOwner = true,
Expand Down Expand Up @@ -5331,18 +5333,22 @@ function switch(caller, command, args)
local is_correct_type, converted_value, err

-- DEBUG:
server.announce(pArgIndex .. " " .. arg.data.name, quote((pArgValue or "nil")), caller)
if DEBUG then
server.announce(pArgIndex .. " " .. arg.data.name, quote((pArgValue or "nil")), caller)
end

if not accepted or arg.data.repeatable then

for _, accepted_type in ipairs(arg.data.type) do

is_correct_type, converted_value, err = dataIsOfType(pArgValue, accepted_type, caller)
-- DEBUG: announce what value this is looking for and what it is attempting to match
server.announce((is_correct_type and "Correct" or "Incorrect") .. (arg.data.required and " Required" or " Optional"),
"Arg Position: " .. pArgIndex .. "\n |Target Type: " .. accepted_type .. "\n | Given Value: " .. tostring(pArgValue) .. "\n | Converted Value: " .. tostring(converted_value) .. "\n | Err: " .. ((not is_correct_type and err) or ""),
caller.peerID
)
if DEBUG then
server.announce((is_correct_type and "Correct" or "Incorrect") .. (arg.data.required and " Required" or " Optional"),
"Arg Position: " .. pArgIndex .. "\n |Target Type: " .. accepted_type .. "\n | Given Value: " .. tostring(pArgValue) .. "\n | Converted Value: " .. tostring(converted_value) .. "\n | Err: " .. ((not is_correct_type and err) or ""),
caller.peerID
)
end

-- if the argument is a segment of text and the rest of the arguments need to be captured and concatenated
if accepted_type == "text" and pArgValue ~= nil and pArgValue ~= "" then
Expand Down Expand Up @@ -5371,13 +5377,15 @@ function switch(caller, command, args)
end

-- DEBUG: announce a failed argument matching
if not accepted and arg.data.required then
server.notify(caller.peerID, "Arg Match Not Found", arg.data.name, 8)
local accepted_types = {}
for _, type_name in ipairs(arg.data.type) do
table.insert(accepted_types, TYPE_ABBREVIATIONS[type_name])
if DEBUG then
if not accepted and arg.data.required then
server.notify(caller.peerID, "Arg Match Not Found", arg.data.name, 8)
local accepted_types = {}
for _, type_name in ipairs(arg.data.type) do
table.insert(accepted_types, TYPE_ABBREVIATIONS[type_name])
end
return false, "ARG REQUIRED", "Argument #" .. arg.index .. " : " .. arg.data.name .. " must be of type " .. table.concat(accepted_types, ", ")
end
return false, "ARG REQUIRED", "Argument #" .. arg.index .. " : " .. arg.data.name .. " must be of type " .. table.concat(accepted_types, ", ")
end
end
server.notify(caller.peerID, "EXECUTING " .. command, " ", 7)
Expand Down

0 comments on commit 036ce5f

Please sign in to comment.