thomasfn

Untitled

Aug 21st, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. print( "-- GATE COMPUTER --" )
  2. print( "Computer ID: " .. os.computerID() )
  3.  
  4. rednet.open("back")
  5.  
  6. -- white = up
  7. -- orange = down
  8. -- blue = back
  9. -- yellow = forward
  10.  
  11. local function FireMotor( col )
  12.     rs.setBundledOutput("left", colours[col])
  13.     sleep(0.4)
  14.     rs.setBundledOutput("left", 0)
  15.     sleep(0.4)
  16. end
  17.  
  18. local function OpenGate()
  19.     print( "Opening gate" )
  20.     for i=1, 3 do
  21.         FireMotor("yellow")
  22.     end
  23.     for i=1, 3 do
  24.         FireMotor("white")
  25.     end
  26. end
  27.  
  28. local function CloseGate()
  29.     print( "Closing gate" )
  30.     for i=1, 3 do
  31.         FireMotor("orange")
  32.     end
  33.     for i=1, 3 do
  34.         FireMotor("lightBlue")
  35.     end
  36. end
  37.  
  38. while true do
  39.     local sender, msg, dist = rednet.receive()
  40.     if (msg == "open_gate") then
  41.         OpenGate()
  42.     end
  43.     if (msg == "close_gate") then
  44.         CloseGate()
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment