Advertisement
KingKevin23

machine_controller

Mar 16th, 2022
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local my_name = "reactor"
  2. local modem_pos = "back"
  3. local protocol = "machine_control"
  4. local redstone_pos = "front"
  5.  
  6. redstone.setAnalogOutput(redstone_pos, 0)
  7. rednet.open(modem_pos)
  8. rednet.host(protocol, my_name)
  9. while true do
  10.     local id, message = rednet.receive(protocol)
  11.     if message == "on" then
  12.         redstone.setAnalogOutput(redstone_pos, 15)
  13.         print("Machine turned on by " .. id)
  14.     elseif message == "off" then
  15.         redstone.setAnalogOutput(redstone_pos, 0)
  16.         print("Machine turned off by " .. id)
  17.     else
  18.         print("Message was not recognized " .. message .. " " .. id)
  19.     end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement