Advertisement
Entityreborn

Mover

Apr 26th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. --[[ startup
  2. id="GLMmkuJ3"
  3. loadstring(http.get("http://pastebin.com/raw.php?i=" .. id).readAll())()
  4. ]]--
  5.  
  6. eng = false
  7. connected = false
  8. modem = false
  9. myChannel = 6636
  10. monitorChannel = 6637
  11.  
  12. for a,b in pairs(rs.getSides()) do
  13.     if peripheral.getType(b) == 'modem' then
  14.         print("Found modem on " .. b .. ", attaching to " .. myChannel)
  15.         print("Hold CTRL-T for one second to stop, CTRL-R to reboot and update.")
  16.         modem = peripheral.wrap(b)
  17.         modem.open(myChannel)
  18.         connected = true
  19.     elseif (peripheral.getType(b) == 'carriage') then
  20.         print("Found carriage on " .. b .. ".")
  21.         eng = peripheral.wrap(b)
  22.     end
  23. end
  24.  
  25. while connected do
  26.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  27.     print("Got message " .. message)
  28.    
  29.     local monitormsg = false
  30.     local direction = false
  31.    
  32.     if (message == "break") then
  33.         connected = false
  34.         monitormsg = "Told to stop."
  35.         break
  36.     elseif (message == "move.down") then
  37.         monitormsg = "Moved down."
  38.         direction = 0
  39.     elseif (message == "move.up") then
  40.         monitormsg = "Moved up."
  41.         direction = 1
  42.     elseif (message == "move.north") then
  43.         monitormsg = "Moved north."
  44.         direction = 2
  45.     elseif (message == "move.south") then
  46.         monitormsg = "Moved south."
  47.         direction = 3
  48.     elseif (message == "move.west") then
  49.         monitormsg = "Moved west."
  50.         direction = 4
  51.     elseif (message == "move.east") then
  52.         monitormsg = "Moved east."
  53.         direction = 5
  54.     end
  55.    
  56.     if (direction ~= false) then
  57.        
  58.         eng.move(direction, false, false)
  59.     end
  60.    
  61.     if (monitormsg) then
  62.         modem.transmit(monitorChannel,myChannel,monitormsg)
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement