35 posts
Location
Norway
Posted 27 July 2012 - 11:16 PM
Would it be possible to do something like this?
local function isKeyDown(key)
-- Check if key is being pressed
end
I 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.
295 posts
Location
In the TARDIS at an unknown place in time.
Posted 28 July 2012 - 01: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.
718 posts
Location
Hawaii
Posted 28 July 2012 - 01: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
496 posts
Location
New Zealand
Posted 28 July 2012 - 01:23 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.
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.
2447 posts
Posted 28 July 2012 - 11: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.