GDragonArcher

chat items

Jul 17th, 2022 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local box = peripheral.find("chatBox")
  2. -- box is the connected Chat Box
  3.  
  4. if box == nil then error("chatBox not found") end
  5.  
  6. local totem = rs.getInput("left") -- boolean, if the door is open
  7. local teleport = rs.getInput("right") -- boolean, if the wall is builded
  8.  
  9. redstone.setAnalogOutput("right", 15)
  10.  
  11. while true do
  12.  
  13. -- with param1, you can check if the message is anything you like.
  14. -- with param2, you can check if the player's name is your name
  15. local event, param1, param2 = os.pullEvent("chat") -- the chunk of the chat box needs to be loaded
  16.     if(param1 == "GDragonArcher") then
  17.        
  18.     if(param2 == "on") then -- param2 is the message and param1 is the player's name
  19.            
  20.         if(totem == false) then
  21.             redstone.setAnalogOutput("left", 15)
  22.             box.sendMessageToPlayer("Activated", "GDragonArcher", "ChatCommands")
  23.             totem = true
  24.         else
  25.             box.sendMessageToPlayer("Already Active","GDragonArcher", "ChatCommands")
  26.         end
  27.            
  28.            
  29.     elseif(param2 == "tp") then
  30.            
  31.         if(teleport == false) then
  32.             box.sendMessageToPlayer("Teleported", "GDragonArcher", "ChatCommands")
  33.             redstone.setAnalogOutput("right", 0)
  34.             teleport = true
  35.         else
  36.             box.sendMessageToPlayer("Teleport Failed", "GDragonArcher", "ChatCommands")
  37.         end
  38.            
  39.      elseif(param2 == "off") then --param2 is the message and param1 is the player's name
  40.            
  41.         if(totem == true) then
  42.             redstone.setAnalogOutput("left", 0)
  43.             box.sendMessageToPlayer("Deactivated","GDragonArcher", "ChatCommands")
  44.             totem = false
  45.         else
  46.             box.sendMessageToPlayer("Error","GDragonArcher", "ChatCommands")
  47.         end
  48.            
  49.       elseif(param2 == "reset") then --param2 is the message and param1 is the player's name
  50.            
  51.         if(teleport == true) then
  52.             redstone.setAnalogOutput("right", 15)
  53.             box.sendMessageToPlayer("Teleport Chamber Reset","GDragonArcher", "ChatCommands")
  54.             teleport = false
  55.         else
  56.             box.sendMessageToPlayer("Error","GDragonArcher", "ChatCommands")
  57.         end
  58.            
  59.      end
  60.        
  61.     end
  62.    
  63.     end
Add Comment
Please, Sign In to add comment