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

anti-terminating

Started by epicowner97, 28 April 2012 - 09:13 PM
epicowner97 #1
Posted 28 April 2012 - 11:13 PM
Hey guys im practicing with CC on a server but everytime i comeback into the server my startup program is terminated and all my computers are broken.
Is there any code that wont let the users terminate the program?
Thanks in advance
Leo Verto #2
Posted 28 April 2012 - 11:24 PM
There are at least two or more threads about this topic, you should search before you ask.
The code I usually use is:

--Put this in front of your code
oldpullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
--Your code
--Put this after your code
os.pullEvent = oldpullEvent
The backing up of os.pullEvent is optional but recommended if youa re not hacking a public computer at spawn. :)/>/>
epicowner97 #3
Posted 28 April 2012 - 11:39 PM
Haha next time i will, tnx alot but can you explain what its meaning?
I'd like t nkow what i write
Leo Verto #4
Posted 29 April 2012 - 12:19 AM
I'm actually not really sure, but I know it works.
I think there was an explanation and several other ways in another thread, but I couldn't find it.
ComputerCraftFan11 #5
Posted 29 April 2012 - 12:50 AM
I'm actually not really sure, but I know it works.
I think there was an explanation and several other ways in another thread, but I couldn't find it.

The only difference between os.pullEvent and os.pullEventRaw is that os.pullEvent has the terminate event.

function os.pullEventRaw( _sFilter )
  return coroutine.yield( _sFilter )
end

function os.pullEvent( _sFilter )
local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )
if event == "terminate" then
  print( "Terminated" )
  error()
end
return event, p1, p2, p3, p4, p5
end