Lion4ever

SchilderTurtle

Sep 1st, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local maxMoves=1000
  2. local lastAction
  3. local reader=peripheral.wrap("left")
  4. local actions={links=turtle.turnLeft,left=turtle.turnLeft,rechts=turtle.turnRight,right=turtle.turnRight,wende=function() turtle.turnLeft() turtle.turnLeft() end}
  5. local move={forward=turtle.forward,geradeaus=turtle.forward,vorwaertz=turtle.forward,vorne=turtle.forward,back=turtle.back,rueckwaertz=turtle.back,zurueck=turtle.back,up=turtle.up,hoch=turtle.up,oben=turtle.up,down=turtle.down,unten=turtle.down,runter=turtle.down}
  6. local lastSign=0
  7. if fs.exists("lastAction") then
  8.     f=fs.open("lastAction","r")
  9.     lastAction = move[f.readAll()]
  10.     f.close()
  11. end
  12. while lastSign<=maxMoves do
  13.     local a,b,c,d= reader.read()
  14.     if not a then
  15.         a,b,c,d=reader.readDown()
  16.     end
  17.     if not a then
  18.         a,b,c,d=reader.readUp()
  19.     end
  20.     if a then
  21.         local text=(a or "")..(b or "")..(c or "")..(d or "")
  22.         local didAction=false
  23.         for i,j in pairs(actions) do
  24.             if text:find(i) then
  25.                 j()
  26.                 didAction=true
  27.                 break
  28.             end
  29.         end
  30.         for i,j in pairs(move) do
  31.             if text:find(i) then
  32.                 lastAction=j
  33.                 f=fs.open("lastAction","w")
  34.                 f.write(i)
  35.                 f.close()
  36.                 didAction=true
  37.                 break
  38.             end
  39.         end
  40.         if text:find("/") and text:find("/")<#text then
  41.             local func=loadstring(text:sub(text:find("/")+1))
  42.             if func then
  43.                 pcall(func)
  44.                 didAction=true
  45.             end
  46.         end
  47.         if didAction then
  48.             lastSign = 0
  49.         else
  50.             print("Unreadable Sign: "..text or "Text missing")
  51.         end
  52.     end
  53.     lastSign=lastSign+1
  54.     repeat until lastAction()
  55. end
Advertisement
Add Comment
Please, Sign In to add comment