Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.wrap("back")
- local Commands = {
- ["core"] = {
- ["args"] = {
- {
- name = "state",
- typeof = "string"
- }
- },
- ["function"] = {
- func = function(self, args)
- print("CORE")
- end
- }
- }
- }
- local function parseCommand(command)
- if command == nil then return end
- local args = {}
- local cmd = ""
- local firstrun = true
- for i in command:gmatch("%S+") do
- if firstrun then
- cmd = i
- firstrun = false
- else
- args[#args + 1] = i
- end
- end
- return cmd, args
- end
- while true do
- local _, command = os.pullEvent("chat_command")
- local cmd, args = parseCommand(command)
- if commands[cmd] ~= nil then
- local wrongArg = false
- for index, value in pairs(Commands[cmd]["args"]) do
- if value.typeof ~= type(args[index]) then
- args[index] = tonumber(args[index])
- if args[index] == nil then
- wrongArg = "type"
- break
- end
- end
- end
- if wrongArg then
- local argsString = ""
- for i,_ in pairs(Commands[cmd]["args"]) do
- argsString = argsString.." ["..Commands[cmd]["args"][i]..name.."]"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement