This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
disable ctrl+T
Started by schrolock, 20 July 2012 - 06:54 PMPosted 20 July 2012 - 08:54 PM
is it available to disable the ctrl+T function to avoid that my programs getting hacked?
Posted 20 July 2012 - 08:57 PM
Hmmm, i don't know. Maybe one of all the posts in the forum about this has an answer.
Seriously, try searching first. There's a lot of posts about this, it's even on the wiki.
Seriously, try searching first. There's a lot of posts about this, it's even on the wiki.
Posted 20 July 2012 - 09:02 PM
ok thx
Posted 21 July 2012 - 09:21 AM
Place this at the top of your code:
os.pullEvent = os.pullEventRaw
Posted 21 July 2012 - 05:37 PM
Place this at the top of your code:os.pullEvent = os.pullEventRaw
Thank You
Posted 25 July 2012 - 11:55 AM
Awesome but cant they just restart it also?
Posted 25 July 2012 - 05:31 PM
Yes, that can't be stopped. but with a suitable startup file, you can make your program show up on reboot again…
Posted 25 July 2012 - 05:48 PM
question, is there a way to detect if they are pushing ctrl + t and stop it before it happens? if so that would be very helpfull… in my code I have an option for the program to autostart where it left off… if i could detect that before it happens i could tell it to automatically start where it left off…
Posted 25 July 2012 - 06:16 PM
ctrl+t will post a "terminate"-event which can be received like any other event. However, os.pullEvent() catches that one and terminates the program. os.pullEventRaw() doesn't. you have to be careful as os.pullEvent() is also used in sleep() or rednet.recieve().
Posted 26 July 2012 - 06:35 AM
ok. how much time is between the recieving of the event and the termination? can you change that time?
Posted 26 July 2012 - 07:01 AM
It varies between processors of the hosting computer (ie the one that runs minecraft). To change that time would definitely include changing the rom.ok. how much time is between the recieving of the event and the termination? can you change that time?
Posted 26 July 2012 - 10:11 AM
To catch the terminate event is very simple, however it will over ride the global os.pullEvent() so you will need to restore it when closing your program to regain ctrl+t functionality.
Add this to the top of your code:
And use this function to restore the original
Add this to the top of your code:
function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
print ("Sorry Ctrl+t is disabled")
sleep(2)
end
return event, p1, p2, p3, p4, p5
end
And use this function to restore the original
function restoreEvent()
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
end