Posted 16 January 2017 - 09:17 PM
Hello!
I was making an ACPI program for ComputerCraft and I tried to test it out by running it and pressing CTRL+S (not holding it) and it's supposed to queue "ACPI-SH" but it didn't! The PK variable did reset like normal though.
Pastebin
Thanks!
I was making an ACPI program for ComputerCraft and I tried to test it out by running it and pressing CTRL+S (not holding it) and it's supposed to queue "ACPI-SH" but it didn't! The PK variable did reset like normal though.
Code
function watch()
_G.pk = {}
local pk = _G.pk
while true do
local event, key = os.pullEvent("key")
if key == 29 or key == keys.r or key == keys.s then
table.insert(pk, key)
_G.pk = pk -- Update the global variable
end
-- Turn the table into a string
local output = ""
for k,v in pairs(pk) do
output = output .. v .. "/"
end
local r = 29 .. "/" .. 19 .. "/"
local s = 29 .. "/" .. 31 .. "/"
if output == r then
-- CTRL+R has been pressed!
os.queueEvent("ACPI-RB")
-- Reset PK
local pk = {}
_G.pk = pk
elseif output == s then
-- CTRL+S has been pressed!
os.queueEvent("ACPI-SH")
-- Reset PK
local pk = {}
_G.pk = pk
end
end
end
function cont()
term.clear()
term.setCursorPos(1,1)
shell.run("shell")
end
parallel.waitForAll(watch, cont)
Pastebin
Thanks!