Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local running = true
- write("Target: ")
- local id = tonumber(read()) or 1
- rednet.open("back")
- local key = {[16]="up",[17]="forward",[18]="down",[30]="turnLeft",[31]="back",[32]="turnRight",[36]="digUp",[37]="dig",[38]="digDown",[22]="placeUp",[23]="place",[24]="placeDown",[28]="end",[57]="stop"}
- local pressed = {}
- local function listen()
- while running do
- local f = key[({os.pullEvent("key")})[2]]
- if f == "end" then
- running = false
- elseif f== "stop" then
- pressed = {}
- elseif f then
- table.insert(pressed,1,f)
- end
- end
- end
- local function execute()
- while running do
- while #pressed == 0 do
- os.pullEvent()
- end
- rednet.send(id,pressed[#pressed])
- table.remove(pressed)
- sleep(0.45)
- end
- end
- parallel.waitForAny(listen,execute)
Advertisement
Add Comment
Please, Sign In to add comment