Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function try_move(key, channel, moves)
- local left_arrow = 263
- local right_arrow = 262
- if moves[key] then
- rednet.send(channel, moves[key])
- print(moves[key])
- elseif key == left_arrow then
- moves[32] = 'dig'
- rednet.send(1, moves[32])
- elseif key == right_arrow then
- moves[32] = 'place'
- rednet.send(1, moves[32])
- else
- rednet.send(1, key .. " pressed")
- end
- end
- write('Enter the bot\'s id: ')
- local bot = tonumber(read())
- shell.run('clear')
- rednet.open('back')
- local moves = {}
- moves[265] = 'up'
- moves[264] = 'down'
- moves[87] = 'forward'
- moves[65] = 'left'
- moves[83] = 'backward'
- moves[68] = 'right'
- moves[32] = 'dig'
- moves[29] = 'rs'
- moves[82] = 'inspect'
- while true do
- local event, key = os.pullEvent("key")
- shell.run('clear')
- try_move(key, 0, moves)
- local _, _, text = os.pullEvent("rednet_message")
- print(text)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement