local function isKeyDown(key) -- Check if key is being pressed endI don't mean something like os.pullEvent(), which would detect if the key is pressed once, but rather something that would detect if the key is being pressed.
[Question] "isKeyDown"?
Started by Mmmmmmmm, Jul 27 2012 10:16 PM
4 replies to this topic
#1
Posted 27 July 2012 - 10:16 PM
Would it be possible to do something like this?
#2
Posted 28 July 2012 - 12:06 AM
local function isKeyDown(keynumber)
local e,key = os.pullEventRaw("key")
if key == keynumber then
<Execute Code>
end
end
Not tested, but I think it might work.
#3
Posted 28 July 2012 - 12:10 AM
Try this, I didn't test it yet:
local function isKeyDown(keyinput) local timer112 = os.startTimer(0) event, key = os.pullEvent() if event == timer and key == timer112 then return false elseif event == "char" or event == "key" then if keyinput == key then return true else return false end else return false end end
#4
Posted 28 July 2012 - 12:23 AM
brett122798, on 28 July 2012 - 12:06 AM, said:
local function isKeyDown(keynumber)
local e,key = os.pullEventRaw("key")
if key == keynumber then
<Execute Code>
end
end
Not tested, but I think it might work.
ComputerCraftFan11, on 28 July 2012 - 12:10 AM, said:
Try this, I didn't test it yet:
local function isKeyDown(keyinput) local timer112 = os.startTimer(0) event, key = os.pullEvent() if event == timer and key == timer112 then return false elseif event == "char" or event == "key" then if keyinput == key then return true else return false end else return false end end
Both of those don't do what the person wants.
@EternalFacepalm Currently no, CC is very event driven with no static checking like that.
#5
Posted 28 July 2012 - 10:09 AM
As more than one person can use a computer at any one time this would not be trivial to add. However I'll try and think of a solution for the next version.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











