Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maxMoves=1000
- local lastAction
- local reader=peripheral.wrap("left")
- local actions={links=turtle.turnLeft,left=turtle.turnLeft,rechts=turtle.turnRight,right=turtle.turnRight,wende=function() turtle.turnLeft() turtle.turnLeft() end}
- 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}
- local lastSign=0
- if fs.exists("lastAction") then
- f=fs.open("lastAction","r")
- lastAction = move[f.readAll()]
- f.close()
- end
- while lastSign<=maxMoves do
- local a,b,c,d= reader.read()
- if not a then
- a,b,c,d=reader.readDown()
- end
- if not a then
- a,b,c,d=reader.readUp()
- end
- if a then
- local text=(a or "")..(b or "")..(c or "")..(d or "")
- local didAction=false
- for i,j in pairs(actions) do
- if text:find(i) then
- j()
- didAction=true
- break
- end
- end
- for i,j in pairs(move) do
- if text:find(i) then
- lastAction=j
- f=fs.open("lastAction","w")
- f.write(i)
- f.close()
- didAction=true
- break
- end
- end
- if text:find("/") and text:find("/")<#text then
- local func=loadstring(text:sub(text:find("/")+1))
- if func then
- pcall(func)
- didAction=true
- end
- end
- if didAction then
- lastSign = 0
- else
- print("Unreadable Sign: "..text or "Text missing")
- end
- end
- lastSign=lastSign+1
- repeat until lastAction()
- end
Advertisement
Add Comment
Please, Sign In to add comment