--[[ ICBM missile control panel by LuaCrawler This goes with the door and launch controller for it to work. for automatic load change the name of the file to startup and remove the extension. @Version: 2.0.0 ]] -- License --[[ ICBM control panel. Launches missiles remotely using player commands. Will have more feature in the future Copyright (C) 2014 LuaCrawler This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ]] -- Variables local delay = 5 local modem = peripheral.wrap("top") local server = 10 local Chan = tonumber(os.getComputerID()) local rChan = tonumber(os.getComputerID()) -- Users table local users = { ["Admin"] = {["password"] = "password", ["permissions"] = "admin"}, } local logo = { } local commands = { ["Add User"] = "Adds a user with permission. You must be a moderator or admin to add the user", ["Remove User"] = "Removes user. Must have moderator or admin privilages.", ["Launch missile"] = "Activates launch handle system,", ["open door"] = "Opens launch bay doors.", ["close door"] = "Closes launch bay doors.", } ---------------------------------------------------------- -- Startup Function local function startup() term.clear() term.setCursorPos(1,1) term.setCursorPos(18,8) term.setTextColor(colors.lime) print("MissileCraft 1.04") term.setCursorPos(18,9) print("'Speedy Skeleton'") sleep(5) term.clear() term.setCursorPos(1,1) term.setTextColor(colors.white) modem.open( Chan ) term.setBackgroundColor(colors.black) modem.open(tonumber(os.getComputerID())) file = fs.open("/.users", "r") dataT = file.readAll() data = textutils.unserialize(dataT) file.close() users = data end ---------------------------------------------------------- local function checkUNamePasswd() local uName while (not users[uName]) or users[uName].password ~= passwd do term.clear() term.setCursorPos(1, 1) textutils.slowPrint("Enter username:", 25) local uName = read() -- Now check store password as variable term.clear() term.setCursorPos(1, 1) textutils.slowPrint("Enter your password:", 25) local passwd = read() if (not users[uName]) or users[uName].password ~= passwd then term.clear() term.setCursorPos(1, 1) term.setTextColor(colors.red) textutils.slowPrint("Incorrect password! Please try again.", 50) term.setTextColor(colors.white) print("") else break end end end ---------------------------------------------------------- local function checkUsrNamePerm() local uName while (not users[uName]) or (users[uName].permissions ~= "admin" and users[uName].permissions ~= "moderator") do term.clear() term.setCursorPos(1, 1) textutils.slowPrint("Enter username for verification", 25) uName = read() if (not users[uName]) or (users[uName].permissions ~= "admin" and users[uName].permissions ~= "moderator") then print("You don't have enough permissions! Please try again.") else break end end end ---------------------------------------------------------- local function save(table,users) local file = fs.open(".users", "w") file.write(textutils.serialize(users)) file.close() end ---------------------------------------------------------- local function addUsr(Name, password, permissions) users[Name] = {} users[Name].password = password users[Name].permissions = permissions save(users, users) end ---------------------------------------------------------- local bar = LoadBar.init(LoadBar.ASCII_BAR_ONLY, nil, 10, 30, 14, nil, nil, nil, nil ) local function doStuff() bar:setMessage( "Loading..." ) for i = 1, 9 do sleep(0.5) bar:triggerUpdate("Initializing component("..(bar:getCurrentProgress()+1).."/9)") end bar:triggerUpdate("Done!") end ---------------------------------------------------------- local function doBar() bar:run( true ) end ---------------------------------------------------------- local function missile_launch() -- Code here... os.loadAPI("/lib/LoadBar") -- Run the loading bar parallel.waitForAll( doBar, doStuff ) term.clear() term.setBackgroundColor(colors.gray) term.setCursorPos(1, 1) for i = 1, 19 do print(" ") end term.setTextColor(colors.yellow) term.setCursorPos(1, 1) textutils.slowPrint("Remote missile launch system" ) textutils.slowPrint("Usage: launch