Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function readData()
- local h=fs.open("houseData","r")
- data = h.readLine()
- action = {}
- for i=1,string.len(data),2 do
- command=string.sub(data,i,i)
- times=tonumber(string.sub(data,i+1,i+1))
- table.insert(action,{command,times})
- end
- end
- function chooseSlot(givenSlot)
- local chosenSlot = givenSlot
- for i=5,16 do
- turtle.select(i)
- if turtle.compareTo(givenSlot) then
- chosenSlot = i
- end
- turtle.select(chosenSlot)
- end
- end
- function placeBehind(times)
- for i = 1,times do
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- function moveForward(times)
- for i=1,times do
- turtle.forward()
- end
- end
- function doAction(command,times)
- if command =="p" then
- chooseSlot(times)
- placeBehind(1)
- elseif command =="f" then
- moveForward(times)
- elseif command =="b" then
- placeBehind(times)
- elseif command =="d" then
- turtle.turnRight()
- moveForward(times)
- elseif command =="a" then
- turtle.turnLeft()
- moveForward(times)
- elseif command =="s" then
- turtle.turnRight()
- turtle.turnRight()
- moveForward(times)
- end
- end
- readData()
- for i=1,#action do
- doAction(action[i][1],action[i][2])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement