Advertisement
QuicksilverBoy

Distanation Switch (BIOS)

Feb 11th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. rs = component.proxy(component.list('redstone')())
  2. modem = component.proxy(component.list('modem')())
  3.  
  4. distanation = 'blue'
  5. invert = false
  6.  
  7. if modem.isWireless() then
  8.     error('The modem must bo wired')
  9. end
  10.  
  11. modem.open(1)
  12.  
  13. --[[sign, name = component.list("sign")()
  14. if name == "sign" then
  15.     comSign = component.proxy(sign)
  16.     _text, reson = comSign.getValue(1)
  17.     if reson ~= "no sign" then
  18.         messageText = "Distanation = \n" .. distanation .. '\nInv = ' .. tostring(invert)
  19.         comSign.setValue(1, messageText)
  20.     end
  21. end
  22. ]]--
  23.  
  24. computer.beep()
  25.  
  26. function waitMessage()
  27.     while true do
  28.         ev, _, _, _, _, dist = computer.pullSignal(10)
  29.         if ev == 'modem_message' then
  30.             return dist
  31.         end
  32.     end
  33. end
  34.  
  35. function open(i)
  36.     if not i then
  37.         rs.setOutput(5, 16)
  38.         rs.setOutput(4, 16)
  39.     else
  40.         rs.setOutput(5, 0)
  41.         rs.setOutput(4, 0)
  42.     end
  43. end
  44.  
  45. function close(i)
  46.     if not i then
  47.         rs.setOutput(5, 0)
  48.         rs.setOutput(4, 0)
  49.     else
  50.         rs.setOutput(5, 16)
  51.         rs.setOutput(4, 16)
  52.     end
  53. end
  54.  
  55. while true do
  56.     d = waitMessage()
  57.     if d == distanation then
  58.         open(invert)
  59.         computer.beep(1500, 1)
  60.     else
  61.         close(invert)
  62.         computer.beep(1500, 1)
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement