Advertisement
Alexr360

Bastion Reciever Main

Feb 20th, 2024 (edited)
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local function bastion()
  2.     local modem = peripheral.find("modem") or error("No modem attached", 0)
  3.     modem.open(15) -- Open 43 so we can receive replies
  4.  
  5.     -- And wait for a reply
  6.     local event, side, channel, replyChannel, message, distance
  7.     repeat
  8.       event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  9.     until channel == 15
  10.  
  11.     -- Process the received message based on its content
  12.     if message == "Bridge" then
  13.         print("Toggling Bridge Gate")
  14.         redstone.setOutput("left", true)  -- Emit a redstone signal to the right
  15.         os.sleep(1)  -- Keep the signal for 1 seconds
  16.         redstone.setOutput("left", false)  -- Turn off the redstone signal
  17.  
  18.     elseif message == "Courtyard" then
  19.         print("Toggling Courtyard Gate")
  20.         redstone.setOutput("right", true)  -- Emit a redstone signal to the right
  21.         os.sleep(1)  -- Keep the signal for 1 seconds
  22.         redstone.setOutput("right", false)  -- Turn off the redstone signal
  23.  
  24.     elseif message == "Remote Connected" then
  25.         modem.transmit(43, 15, "Connected to Bastion Network")
  26.         print("Remote Connected")
  27.  
  28.     elseif message == "Lockdown" then
  29.         print("Toggling Lockdown")
  30.         redstone.setOutput("front", true)  -- Emit a redstone signal to the right
  31.         os.sleep(1)  -- Keep the signal for 1 seconds
  32.         redstone.setOutput("front", false)  -- Turn off the redstone signal
  33.  
  34.     end
  35. end
  36.  
  37. term.clear()
  38. term.setCursorPos(1, 1)
  39. print("Bastion Network Online!")
  40.  
  41. -- Main loop
  42. while true do
  43.     bastion()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement