Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local box = peripheral.find("chatBox")
- -- box is the connected Chat Box
- if box == nil then error("chatBox not found") end
- local totem = rs.getInput("left") -- boolean, if the door is open
- local teleport = rs.getInput("right") -- boolean, if the wall is builded
- redstone.setAnalogOutput("right", 15)
- while true do
- -- with param1, you can check if the message is anything you like.
- -- with param2, you can check if the player's name is your name
- local event, param1, param2 = os.pullEvent("chat") -- the chunk of the chat box needs to be loaded
- if(param1 == "GDragonArcher") then
- if(param2 == "on") then -- param2 is the message and param1 is the player's name
- if(totem == false) then
- redstone.setAnalogOutput("left", 15)
- box.sendMessageToPlayer("Activated", "GDragonArcher", "ChatCommands")
- totem = true
- else
- box.sendMessageToPlayer("Already Active","GDragonArcher", "ChatCommands")
- end
- elseif(param2 == "tp") then
- if(teleport == false) then
- box.sendMessageToPlayer("Teleported", "GDragonArcher", "ChatCommands")
- redstone.setAnalogOutput("right", 0)
- teleport = true
- else
- box.sendMessageToPlayer("Teleport Failed", "GDragonArcher", "ChatCommands")
- end
- elseif(param2 == "off") then --param2 is the message and param1 is the player's name
- if(totem == true) then
- redstone.setAnalogOutput("left", 0)
- box.sendMessageToPlayer("Deactivated","GDragonArcher", "ChatCommands")
- totem = false
- else
- box.sendMessageToPlayer("Error","GDragonArcher", "ChatCommands")
- end
- elseif(param2 == "reset") then --param2 is the message and param1 is the player's name
- if(teleport == true) then
- redstone.setAnalogOutput("right", 15)
- box.sendMessageToPlayer("Teleport Chamber Reset","GDragonArcher", "ChatCommands")
- teleport = false
- else
- box.sendMessageToPlayer("Error","GDragonArcher", "ChatCommands")
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment