This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Ctrl-T
Started by Csstform, 16 January 2014 - 10:29 PMPosted 16 January 2014 - 11:29 PM
Termination blocking methods please and thankyou!
Posted 16 January 2014 - 11:35 PM
how very demanding, didn't bother searching or doing any of your own research?!
nothing 'blocks' termination…
everything that allows termination uses os.pullEvent, os.pullEvent's implementation is as follows
as you can see it checks for the terminate event and ends the program when detected… as such to stop termination you must use either os.pullEventRaw or coroutine.yield.
nothing 'blocks' termination…
everything that allows termination uses os.pullEvent, os.pullEvent's implementation is as follows
function os.pullEvent( _sFilter )
local eventData = { os.pullEventRaw( _sFilter ) }
if eventData[1] == "terminate" then
error( "Terminated", 0 )
end
return unpack( eventData )
end
as you can see it checks for the terminate event and ends the program when detected… as such to stop termination you must use either os.pullEventRaw or coroutine.yield.
Posted 16 January 2014 - 11:47 PM
Posted 16 January 2014 - 11:49 PM
Yes, basically as theoriginalbit said, you want to replace all your 'os.pullEvent' occurrences with 'os.pullEventRaw'. If you do this, however, make sure it doesn't have infinite loops etc.
Also, always search before asking. A quick search uncovered numerous similar questions.
Also, always search before asking. A quick search uncovered numerous similar questions.
Posted 17 January 2014 - 12:20 AM
Bear in mind that while Ctrl+T can be blocked, there's no way to prevent someone from doing what they like with your system should their character get physical access to it. A disk drive, a disk with an empty startup script, and Ctrl+R is all that's needed to get a command line. A pickaxe is an even simpler method of stopping your script.
Posted 17 January 2014 - 12:31 AM
A pickaxe is an even simpler method of stopping your script.
That just made my day :D/>
Posted 17 January 2014 - 12:53 AM
still not a fan of that phrasing, CTRL+T is not being 'blocked', termination is being prevented, but nothing is being blocked. CTRL+T still works and still fires a termination event when you use any function other than os.pullEvent, its just you're choosing to ignore the event, thus preventing termination.Bear in mind that while Ctrl+T can be blocked
Posted 17 January 2014 - 04:20 AM
You're blocking the event from stopping your script. I'm not sure why you're splitting hairs, it's not even an important distinction.
Posted 17 January 2014 - 07:04 AM
I don't quite like his phrasing either (you can indeed block that particular use of Ctrl-T, in that users can no longer terminate scripts with it), but I believe I see his point: Information given should be accurate. The combo itself cannot be disabled, and the event still fires when it's pressed. Altering the way it's handled in order to prevent a certain outcome doesn't change that.
Most simply ignore the thrown event, but it's still there and can be used for other purposes. Making a script exit "cleanly" would be a good example.
Most simply ignore the thrown event, but it's still there and can be used for other purposes. Making a script exit "cleanly" would be a good example.
Posted 17 January 2014 - 02:35 PM
No your not, because the event doesn't even stop your script in the first place… a function stops your script which you are choosing to use (os.pullEvent). Btw why use os.pullEventRaw, when it is simply a wrapper for coroutine.yield?You're blocking the event from stopping your script. I'm not sure why you're splitting hairs, it's not even an important distinction.
Posted 17 January 2014 - 10:50 PM
Sorry for not searching, but thanks for te help. :P/>