hathfury

MC Xmas

Dec 26th, 2022 (edited)
2,951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | Source Code | 0 0
  1. local MSG_CODE = 'm'
  2.  
  3. -- Update this script
  4. fs.delete( "startup-update" )
  5. shell.run( "pastebin get DUv0cGQv startup-update" )
  6. if fs.exists( "startup-update" ) then
  7.   fs.delete( "startup" )
  8.   fs.move( "startup-update", "startup" )
  9.   print( "Startup program updated!\n" )
  10. end
  11.  
  12. local id, msg
  13. local lbl = os.getComputerLabel()
  14. local rec_id = tonumber(string.sub(lbl,4,lbl:len()))
  15. print("Listening for position: ", rec_id)
  16. rec_id = rec_id + 1
  17. rednet.open("top")
  18. while true do
  19.   id, msg = rednet.receive(nil,5)
  20.   if (id == nil or string.sub(msg,1,1) ~= MSG_CODE) then
  21.     -- Ignore
  22.   elseif (string.sub(msg,rec_id,rec_id) == '1') then
  23.     redstone.setOutput("back", true)
  24.   else
  25.     redstone.setOutput("back", false)
  26.   end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment