Shnupbups

ComputerCraft CCCustomCommands BETA 1.0

Mar 18th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. function runCmd(cmd,user)
  2.  shell.run("commands/"..cmd,user)
  3. end
  4. function cmdBlockRun(side,cmd,player)
  5.  local cmdB = peripheral.wrap(side)
  6.  if player then
  7.   local cmd = string.gsub(cmd,"&p",player)
  8.   cmdB.setCommand(cmd)
  9.  else
  10.   cmdB.setCommand(cmd)
  11.  end
  12.  cmdB.runCommand()
  13.  cmdB.setCommand("")
  14. end
  15. if not fs.exists("commands") then
  16.  fs.makeDir("commands")
  17. end
  18. while true do
  19.  local _,user,cmd = os.pullEvent("chat_message")
  20.  print(user.." typed "..cmd)
  21.  if string.byte(cmd) == 47 then
  22.   local cmd = string.gsub(cmd,"/","",1)
  23.   if fs.exists("commands/"..cmd) then
  24.    print("Valid command! Running...")
  25.    runCmd(cmd,user)
  26.   else
  27.    print("Invalid command!")
  28.   end
  29.  else
  30.   print("Not a command!")
  31.  end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment