Note: there is no way to stop Ctrl+S or Ctrl+R
Stop Terminating
well stopping someone from terminating your program can be really useful and the fact that you only need this line to do it makes it better
os.pullEvent = os.pullEventRawnow for an explaination
The way ComputerCraft handles terminates is if Ctrl+T is held for 1 second(correct me if im wrong) it will send a 'terminate' event
now os.pullEvent acts on this event and then terminates. how it terminates:
Spoiler
and by doing that line of code it overrides os.pullEvent (which handles terminates) with os.pullEventRaw which doesn't check for the terminate event, basically os.pullEvent was built in to check for terminate and os.pullEventRaw wasn't even though they provide same functionalityCustom Terminates
well this is different you have to code os.pullEvent to handle the terminate how you want so the way I like to do it is
we want to override os.pullEvent to handle the terminate how we want so we could do something like this
os.pullEvent = function( _sFilter )
eventData = {os.pullEventRaw( _sFilter } -- os.pullEventRaw will give us the raw event data and store it in this table
if eventData[1] == "terminate" then -- identify the event and see if its terminate
programName = shell.getRunningProgram()
error("User has terminated the program: "..programName,0)
-- this example changes it to say the text between the quotes and then the name of the program
-- change the code after the 'if' to do whatever you want with the terminate even if its nothing
end
end
now basically this code above can be changed to handle your events however you want as long as you code it to do soI hope this tutorial helped and provided the information you needed if it didn't please leave a comment
be sure to also leave some feedback (good or bad I don't mind)











