Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runCmd(cmd,user)
- shell.run("commands/"..cmd,user)
- end
- function cmdBlockRun(side,cmd,player)
- local cmdB = peripheral.wrap(side)
- if player then
- local cmd = string.gsub(cmd,"&p",player)
- cmdB.setCommand(cmd)
- else
- cmdB.setCommand(cmd)
- end
- cmdB.runCommand()
- cmdB.setCommand("")
- end
- if not fs.exists("commands") then
- fs.makeDir("commands")
- end
- while true do
- local _,user,cmd = os.pullEvent("chat_message")
- print(user.." typed "..cmd)
- if string.byte(cmd) == 47 then
- local cmd = string.gsub(cmd,"/","",1)
- if fs.exists("commands/"..cmd) then
- print("Valid command! Running...")
- runCmd(cmd,user)
- else
- print("Invalid command!")
- end
- else
- print("Not a command!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment