Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local pressingKeys = {}
- local keysToDirectionsMap = {
- [keys.w] = "front",
- [keys.a] = "left",
- [keys.s] = "back",
- [keys.d] = "right",
- }
- local function BroadcastDirection(direction)
- print(direction)
- rednet.broadcast(direction, "u")
- end
- local function IfRemapThenBroadcast()
- for i,v in pairs(pressingKeys) do
- if v==true then
- if keysToDirectionsMap[i] then
- BroadcastDirection(keysToDirectionsMap[i])
- end
- end
- end
- end
- while true do
- local e, key = os.pullEvent()
- if e == "key" then
- pressingKeys[key] = true
- elseif e == "key_up" then
- pressingKeys[key] = nil
- end
- IfRemapThenBroadcast()
- end
- rednet.close("back")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement