-
-
Save SirEndii/2002973af6e983f48d5cf7a225d7257a to your computer and use it in GitHub Desktop.
Chat Box Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box = peripheral.wrap("chatBox_4") | |
-- box is the connected Chat Box | |
local open = rs.getInput("left") -- boolean, if the door is open | |
local wall = rs.getInput("right") -- boolean, if the wall is builded | |
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(param2 == "Open the door") then -- param2 is the message and param1 is the player's name | |
if(open == false) then | |
-- send a message and activate the signal, if the door is closed | |
box.sendMessage("Sure, whatever you want") | |
redstone.setAnalogOutput("left", 15) | |
open = true | |
else | |
box.sendMessage("The door is already open.") | |
end | |
elseif(param2 == "Close the door") then | |
if(open == true) then | |
box.sendMessage("Sure, whatever you want") | |
redstone.setAnalogOutput("left", 0) | |
open = false | |
else | |
box.sendMessage("The door isn't open.") | |
end | |
elseif(param2 == "Build the wall") then | |
if(wall == false) then | |
box.sendMessage("Sure, whatever you want") | |
redstone.setAnalogOutput("right", 15) | |
wall = true | |
else | |
box.sendMessage("The wall is already here!") | |
end | |
elseif(param2 == "Destroy the wall") then | |
if(wall == true) then | |
box.sendMessage("Sure, whatever you want") | |
redstone.setAnalogOutput("right", 0) | |
wall = false | |
else | |
box.sendMessage("There is no wall") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment