This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Xenthera's profile picture

os.pullEventRaw

Started by Xenthera, 07 May 2013 - 10:32 AM
Xenthera #1
Posted 07 May 2013 - 12:32 PM
Quick question, i'm writing a gui and i'm using os.pullEventRaw to catch the termination event. However if I use read() it's possible to terminate while entering text. How do I stop this?
superaxander #2
Posted 07 May 2013 - 12:35 PM
Overwrite pullEvent with pullEventRaw
Xenthera #3
Posted 07 May 2013 - 12:46 PM
Duh… thanks
theoriginalbit #4
Posted 07 May 2013 - 09:13 PM
make sure that you restore it after finished with the read though.
PixelToast #5
Posted 07 May 2013 - 11:38 PM

local oldpull=os.pullEvent
os.pullEvent=os.pullEventRaw
local function main()
-- do stuff here
end
local a,b=pcall(main)
if not a then
print(b)
os.pullEvent("key")
end
os.pullEvent=oldpull
will catch errors, ensuring it restores