--#####################user variables######################## local w,h = term.getSize() local wm, hm, monitor local machine = "back" local lights = "right" local Monitor = "top" local Modem = "left" local password = "necas" local opentime = 120 local systime = 2 local title = "Welcome NeluxOS" local iniText = "Iniciating system test" local lightsText = "Lights on?" local lightsOtext = "Lights stay off" local passwordText = "Password:" local passwordCtext = "Password correct!" local passwordItext = "Password incorrect!" local factoryWtext = "Factory is working..." local factoryStext = "Factory has stop" --##############get monitor############## function startMonitor() peripheral.call(Monitor, "write", "Test") monitor = peripheral.wrap(Monitor) wm, hm = monitor.getSize() end --#####clear both shell and monitor##### function clearScreen() term.clear() term.setBackgroundColor(colors.black) term.setTextColor(colors.green) monitor.clear() monitor.setBackgroundColor(colors.black) monitor.setTextColor(colors.green) monitor.setTextScale(.5) end --###keep first line and clear all rest### function cleanline() monitor.clearLine(2,x) term.clearLine(2,x) end --###########tittle position######### function screenTpos() term.setCursorPos(1,1) monitor.setCursorPos(1,1) end --#########content position######## function screenGpos() term.setCursorPos(1,2) monitor.setCursorPos(1,2) end --#####start modem - "under test"#### function startModem() modem = peripheral.wrap(Modem) modem.open(0) modem.isOpen(0) --modem.closeAll() end --#### X function echo's to all present devices ### x = function() print(t) monitor.write(t,wm) modem.transmit(0,1,t) end --######initiating peripherals##### startMonitor() startModem() --####gets X/Y and the routine aware of changes in resolution### for k,v in pairs(peripheral.getMethods(Monitor)) do print(v) print("Terminal size = " .. w .. "," .. h) print("Monitor size = " .. wm .. "," .. hm) end --########LOGIC TiME####### clearScreen() screenTpos() t = title x() sleep(systime) screenGpos() t = iniText x() sleep(systime) sleep(4) cleanline() while true do screenGpos() t = lightsText x() local input = read() if input == "yes" then cleanline() screenGpos() rs.setOutput(lights,true) else cleanline() screenGpos() t = lightsOtext x() end cleanline() screenGpos() t = passwordText x() local input = read("*") if input == password then cleanline() screenGpos() t = passwordCtext x() sleep(systime) rs.setOutput(machine,true) cleanline() screenGpos() t = factoryWtext x() sleep(opentime) screenGpos() rs.setOutput(machine,false) t = factoryStext x() cleanline() screenGpos() else t = passwordItext x() sleep(2) os.shutdown() --shell.run(boolean) clearScreen() screenTpos() end end
Edited by neluxjanz, 10 July 2015 - 01:15 PM.