Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keymap = {
- [340] = "up",
- [341] = "down",
- [87] = "forward",
- [265] = "forward",
- [65] = "turnLeft",
- [263] = "turnLeft",
- [83] = "back",
- [264] = "back",
- [68] = "turnRight",
- [262] = "turnRight",
- [32] = "exit"
- }
- while true do
- local e, key, held = os.pullEvent("key")
- local inst
- for k, v in pairs(keymap) do
- if k == key then
- inst = v
- break
- end
- end
- if inst ~= nil then
- if inst == "exit" then
- return
- end
- term.write(inst)
- if (turtle[inst])() then
- print()
- else
- term.clearLine()
- term.setCursorPos(1, select(2, term.getCursorPos()))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment