196 posts
Location
Hiding in Online Storage
Posted 11 March 2015 - 11:25 PM
So, I am making a program that I do not want ayone using being able to access the files. So, when I need to use os.pullEvent(), I use os.pullRawEvent() to stop someone from being able to Ctrl + T out of the program and wreak havoc. If I use sleep() or read(), as far as I know, they both use os.pullEvent(). How would I go about remaking sleep() and read() so that the programs that they are in cannot be terminated. Thanks!
Edited on 11 March 2015 - 10:27 PM
113 posts
Location
This page
Posted 11 March 2015 - 11:29 PM
If you have
os.pullEvent = os.pullEventRaw
near the start of your code, it will change os.pullEvent to os.pullEventRaw for all programs (until you change it back or restart the computer)
If you want to save the old pullEvent (which you should) do
local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
That way you can do
os.pullEvent = oldPull
to change it back.
213 posts
Posted 11 March 2015 - 11:30 PM
I believe you are not quite understanding how pullEvent and pullEventRaw work. if you call os.pullEventRaw or not when events are passed they will still go to os.pullEvent to counter this we can actually redefine the function. pullEvent and pullEventRaw are exactly the same functions with the same handling except pullEvent handles terminate events specially.
As simply put as possible this will completely override os.pullEvent and terminate
os.pullEvent = os.pullEventRaw
EDIT: ninja'd
Edited on 11 March 2015 - 10:31 PM
196 posts
Location
Hiding in Online Storage
Posted 11 March 2015 - 11:30 PM
If you have
os.pullEvent = os.pullEventRaw
near the start of your code, it will change os.pullEvent to os.pullEventRaw for all programs (until you change it back or restart the computer)
If you want to save the old pullEvent (which you should) do
local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
That way you can do
os.pullEvent = oldPull
to change it back.
That should work, thank you!
Edited on 11 March 2015 - 10:31 PM
355 posts
Location
Germany
Posted 11 March 2015 - 11:30 PM
if you override the os.pullEvent function with os.pullEventRaw everything works as you are intending:
os.pullEvent = os.pullEventRaw
Thats it