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

[Question] control T protection

Started by ewart4fun, 07 September 2012 - 08:48 PM
ewart4fun #1
Posted 07 September 2012 - 10:48 PM
hi all.
i want to disable terminate for my program, but it wont work.
does anyone know how to disable terminate in this program?

--config
menuname = "informationdesk"
programname = "startup"
updatername = "updater"
updaterpass = "hello"
shellpass = "peanut"
function clear()
term.clear()
term.setCursorPos(1, 1)
end
local w,h = term.getSize()
function printCentred( y, s )
	local x = math.floor((w - string.len(s)) / 2)
	term.setCursorPos(x,y)
	term.clearLine()
	term.write( s )
end
local nOption = 1
-- Display menu
local function drawMenu()
	term.clear()
	term.setCursorPos(1,1)
	term.write(menuname)
	term.setCursorPos(w-11,1)
	if nOption == 1 then
	term.write( "OPTION 1" )
	elseif nOption == 2 then
	term.write( "OPTION 2" )
	else
	term.write( "OPTION 3" )
	end
end
-- Display the frontend
term.clear()
local function drawFrontend()
	clear()
	printCentred( math.floor(h/2) - 3, "" )
	printCentred( math.floor(h/2) - 2, "SELECT AN OPTION" )
	printCentred( math.floor(h/2) - 1, "" )
	printCentred( math.floor(h/2) + 0, ((nOption == 1) and "[ Send message ]") or "Send message" )
	printCentred( math.floor(h/2) + 1, ((nOption == 2) and "[ Main menu ]") or "Main menu" )
printCentred( math.floor(h/2) + 2, "" )
end
drawMenu()
drawFrontend()
while true do
drawMenu()
drawFrontend()
local e,p = os.pullEventRaw()
	if e == "key" then
		local key = p
		if key == 17 or key == 200 then
			-- Up
			if nOption > 1 then
				nOption = nOption - 1
				drawMenu()
				drawFrontend()
			end
		elseif key == 31 or key == 208 then
			-- Down
			if nOption < 2 then -- Change 3 by the number of option.
				nOption = nOption + 1
				drawMenu()
				drawFrontend()
			end
		elseif key == 28 then
			-- Enter
			break
		end
	end
end

-- Conditions
if nOption == 1 then
clear()
print("enter your name")
	 name = read()
	 print("enter your message")
	 msg = read()
	 msg2 = " "..msg
	 rednet.send(host, name..msg2)
	 shell.run(programname)
else
clear()
	 shell.run(programname)
end
Cranium #2
Posted 07 September 2012 - 10:58 PM
Did I not JUST answer this 45 minutes ago? PLEASE for the love of GOD, use those things you call eyes, and look on the forums before you post!THIS HAS BEEN ANSWERED! There should be no reason not to read around a bit. It's even on the same page as this post…

EDIT: Just read this after a bit, and realized it's WAY too mean.
To protect your programs from CTRL+T, just add os.pullEvent = os.pullEventRaw at the top of your code.
Edited on 07 September 2012 - 09:14 PM
ewart4fun #3
Posted 08 September 2012 - 06:24 AM
it worked thx