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?
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