Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function goFor(n)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Going forward "..n.." blocks.")
- for n=1,n do
- rs.setOutput("left",true)
- os.sleep(1)
- rs.setOutput("left",false)
- os.sleep(0.5)
- rs.setOutput("right",true)
- os.sleep(0.2)
- rs.setOutput("right",false)
- os.sleep(0.2)
- end
- end
- function reset()
- term.clear()
- term.setCursorPos(1,1)
- term.write("How many blocks to go forward?")
- term.setCursorPos(1,2)
- term.write("Blocks: ")
- term.setCursorPos(9,2)
- term.setCursorBlink(true)
- str = ""
- end
- reset()
- while true do
- event,char = os.pullEvent()
- if event == "char" then
- if char == "0" or char == "1" or char == "2" or char == "3" or char == "4" or char == "5" or char == "6" or char == "7" or char == "8" or char == "9" then
- if #str < 2 then
- str = str..char
- term.setCursorPos(9,2)
- term.write(str.." ")
- term.setCursorPos(9,2)
- term.write(str)
- term.setCursorBlink(true)
- end
- end
- elseif event == "key" then
- if char == 28 and #str > 0 then
- goFor(tonumber(str))
- reset()
- elseif char == 14 and #str > 0 then
- str = string.sub(str,1,#str-1)
- term.setCursorPos(9,2)
- term.write(str.." ")
- term.setCursorPos(9,2)
- term.write(str)
- term.setCursorBlink(true)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment