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

ICBM Launch System With Touchscreen Password ( Advanced Pc )

Started by Jester, 09 January 2015 - 08:49 PM
Jester #1
Posted 09 January 2015 - 09:49 PM
Hi
I recreated a program but you can still terminate it eventho i added this :
local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
Now how can i improve this program and make it unterminatable.


local mon = peripheral.wrap("top")
local pass = "1234"
local passlen = string.len(pass)
local press = "";
tblpad = {};
for i=0,10 do
tblpad[i] = {}
		for x=0,10 do
				tblpad[i][x] = "x"
		end
end


tblpad[2][2] = "1"
tblpad[4][2] = "2"
tblpad[6][2] = "3"
tblpad[2][3] = "4"
tblpad[4][3] = "5"
tblpad[6][3] = "6"
tblpad[2][4] = "7"
tblpad[4][4] = "8"
tblpad[6][4] = "9"
tblpad[4][5] = "0"

function drawpad()
		mon.setBackgroundColor(colors.blue)
		mon.setCursorPos(1,1)
		mon.write(" Code?  ")
		mon.setCursorPos(1,2)
		mon.write(" 1 2 3  ")
		mon.setCursorPos(1,3)
		mon.write(" 4 5 6 ")
		mon.setCursorPos(1,4)
		mon.write(" 7 8 9 ")
		mon.setCursorPos(1,5)
		mon.write("   0   ")
end

function countdown(c)

		for i=1,c do
				mon.setCursorPos(1,1)
				mon.write("	   ")
				mon.setCursorPos(1,2)
				mon.write("	   ")
				mon.setCursorPos(1,3)
				mon.write("   ".. c .."   ")
				mon.setCursorPos(1,4)
				mon.write("	   ")
				mon.setCursorPos(1,5)
				mon.write("	   ")
				sleep(1)
				c = c-1
		end
end

function codeaccept()
rs.setOutput('left', true)
		mon.setBackgroundColor(colors.red)
		mon.setCursorPos(1,1)
		mon.write("-------")
		mon.setCursorPos(1,2)
		mon.write("Prepare")
		mon.setCursorPos(1,3)
		mon.write("  To   ")
		mon.setCursorPos(1,4)
		mon.write("Launch ")
		mon.setCursorPos(1,5)
		mon.write("-------")
sleep(5)
end
function after()
rs.setOutput('back', true) -- Activates Launcher
		mon.setBackgroundColor(colors.red)
		mon.setCursorPos(1,1)
		mon.write("-------")
		mon.setCursorPos(1,2)
		mon.write("Standby")
		mon.setCursorPos(1,3)
		mon.write("  For  ")
		mon.setCursorPos(1,4)
		mon.write("Impact ")
		mon.setCursorPos(1,5)
		mon.write("-------")
sleep(2)
rs.setOutput('back', false)
rs.setOutput('left', false)
sleep(10)
end


function opendoor()
codeaccept()
countdown(10)
after()
os.reboot()
end

function wrongpass()
rs.setOutput('left', true) -- Activates the Siren
		mon.setBackgroundColor(colors.red)
		mon.setCursorPos(1,1)
		mon.write("		")
		mon.setCursorPos(1,2)
		mon.write(" CODE   ")
		mon.setCursorPos(1,3)
		mon.write("		")
		mon.setCursorPos(1,4)
		mon.write("DENIED! ")
		mon.setCursorPos(1,5)
		mon.write("		")
		sleep(20)
rs.setOutput('left', false)
		drawpad()
end
drawpad()

while true do
		event, side, xPos, yPos = os.pullEvent("monitor_touch")
		if tblpad[xPos][yPos] ~= "x" then
				mon.setCursorPos(xPos, yPos)
				mon.setBackgroundColor(colors.red)
				mon.write(tblpad[xPos][yPos])
				sleep(0.2)
				mon.setCursorPos(xPos, yPos)
				mon.setBackgroundColor(colors.green)
				mon.write(tblpad[xPos][yPos])
				press = press .. tblpad[xPos][yPos]
				if string.len(press) == passlen and press == pass then
						press = ""
						opendoor()
				elseif string.len(press) == passlen and press ~= pass then
						press = ""
						wrongpass()
				end
		end
end
Edited on 10 January 2015 - 01:32 PM
KingofGamesYami #2
Posted 09 January 2015 - 11:28 PM
Rebooting the computer and running startup (Control+R and Control+S) are hardcoded into the java side of the mod. There is nothing you can do about them, however you can disable Control+T and name the script startup. This is still vulnerable, since if a startup script is detected on a disk drive, it will run that. To make it totally secure, you must encase your computer in bedrcock, with one side open. Then add a startup script.
safetyscissors #3
Posted 10 January 2015 - 03:41 AM
If not interminable, maybe a deadman switch is close enough?
Maybe use this primary to output a redstone signal or join a network. Then hide a bunch of computers set to autolaunch if the signal is interrupted by a reset or terminate.

It does whats advertised cleanly. The os.reboot may not be desirable if startup is not available.
I might suggest grouping the print screens as a function to reduce the copypasting and future maintenance
Spoiler


local function printScreen(text)
	 for linepos,line in pairs(text) do
		  mon.setCursorPos(1,linepos)
		  mon.write(line)
	 end
end

function wrongpass()
	 --#siren on
	 mon.setBackgroundColor(colors.red)
	 printScreen({
		  "	   ",
		  " CODE  ",
		  "	   ",
		  " DENIED",
		  "	   "})
	 --#wait
	 --#reset
end
Lyqyd #4
Posted 10 January 2015 - 07:09 AM
Moved to Ask a Pro.
Jester #5
Posted 10 January 2015 - 02:35 PM
The main thing is I can't make it unterminatable, and that's the main thing i want to avoid the CNTR-T !
Dragon53535 #6
Posted 10 January 2015 - 07:54 PM
The main thing is I can't make it unterminatable, and that's the main thing i want to avoid the CNTR-T !
But you've already done that…


local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw