Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer = require("computer")
- local component = require("component")
- local redstone = component.redstone
- local debug = component.debug
- local event = require ("event")
- local keyboard = require("keyboard")
- local keys = keyboard.keys
- local function getKeyPress()
- local _, _, _, keycode = event.pull(0.1, "key_down")
- return keys[keycode]
- end
- local char_space = string.byte(" ")
- local char_a = string.byte("a")
- local char_b = string.byte("b")
- local runningA = true
- function unknownEvent()
- end
- local myEventHandlers = setmetatable({}, {__index = function() return unknownEvent end})
- function myEventHandlers.key_up(adress, char, code, playerName)
- if (char == char_space) then
- runningA = false
- end
- if (char == char_a) then
- runCmd("set timer 20000", "set timer 10000", 10, 10)
- end
- if (char == char_b) then
- runningB = false
- end
- end
- function handleEvent(eventID, ...)
- if (eventID) then
- myEventHandlers[eventID](...)
- end
- end
- function exit()
- os.exit()
- end
- function runCmd(cmd1, cmd2, sleep, repeat)
- i = 0
- while i <= repeat do
- debug.runCommand(cmd1)
- os.sleep(sleep)
- debug.runCommand(cmd2)
- os.sleep(sleep)
- i = i + 1
- end
- end
- while runningA do
- handleEvent(event.pull())
- end
Advertisement
Add Comment
Please, Sign In to add comment