Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Made by Craniumkid22
- --This code is free to use, under a few conditions:
- --1. DO NOT claim this as your own work!
- --2. If you change this code, feel free to contact me on the CC forums, user-Craniumkid22.
- --3. if you have questions about any of this code, feel free to contact me as well.
- --CREDITS:
- --Huge thanks to Lyqyd for pounding the necessity of local variables into my thick skull.
- --Major credit goes to Pharap for helping me squash bugs, and helping with the Slots program.
- --Thanks to MysticT for helping with the logging function. Helps me with bugs.
- --Thanks to PaymentOption/Grim Reaper for suggesting to break this atrociously long script into separate files.
- --
- --debug notes--
- --add mass fabricator
- --remove redstone
- -- variables
- local controlTable = {}
- local symbol = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}
- local menu = {
- "Production Control",
- "Reactor Control",
- "Lights",
- "Maintenance",
- "Games",
- "Shutdown"
- }
- local answers = {
- "It is Certain ",
- " Decidedly So ",
- " No ",
- " Yes ",
- " No doubt ",
- " Never ",
- " Unknown ",
- " Ask again ",
- " Doubtful ",
- " Most Likely ",
- "Cannot predict",
- " Probably not ",
- " Stars say no ",
- " For sure "
- }
- local gMenu = {
- "Lucky Dice",
- "Magic 8 Block",
- "Card Slots",
- "Main Menu"
- }
- local mMenu = {
- "System Status",
- "Run initialization",
- "Return to Main menu"
- }
- local rMenu = {
- "Start Reactor",
- "Shutdown Reactor",
- "Return to Main menu"
- }
- local pMenu = {
- "Macerator",
- "Furnace",
- "Compressor",
- "Extractor",
- "RedPower Pump",
- "Blockbreaker Array",
- "Mining Well",
- "Quarry",
- "Buildcraft Pump",
- "Forcefield",
- "Return to Main menu"
- }
- local colorOpt={
- "Redstone/Red alloy wire",
- "White",
- "Orange",
- "Magenta",
- "Light Blue",
- "Yellow",
- "Lime",
- "Pink",
- "Gray",
- "Light Gray",
- "Cyan",
- "Purple",
- "Blue",
- "Brown",
- "Green",
- "Red",
- "Black"
- }
- local eType={
- "None",
- "BatBox",
- "MFE",
- "MFSU"
- }
- local IC2power={
- "None",
- "Generator",
- "Geothermal Generator",
- "Water Mill",
- "Wind Mill",
- "Solar Panel",
- "Nuclear Reactor"
- }
- local BCpower={
- "Redstone Engine",
- "Steam Engine",
- "Combustion Engine",
- "Electric Engine"
- }
- local pTypeX={
- "RedstoneEngine",
- "SteamEngine",
- "CombustionEngine",
- "ElectricEngine"
- }
- local sSide = {
- "left",
- "right",
- "top",
- "bottom",
- "back",
- "front"
- }
- local modslist = {
- "IndustrialCraft 2",
- "RedPower 2",
- "Buildcraft",
- "Immibis' Forcefields"
- }
- local machineList = {
- "Lights",
- "RedstoneEngine",
- "SteamEngine",
- "CombustionEngine",
- "ElectricEngine",
- "Reactor",
- "Coolant",
- "Macerator",
- "Furnace",
- "Compressor",
- "Extractor",
- "RedPowerPump",
- "BlockbreakerArray",
- "MiningWell",
- "Quarry",
- "BuildcraftPump",
- "Forcefield"
- }
- --peripheral check
- for i=1,#sSide do
- if peripheral.isPresent(sSide[i]) then
- if peripheral.getType(sSide[i]) == "monitor" then mon = peripheral.wrap(sSide[i]) pM = true
- elseif peripheral.getType(sSide[i]) == "disk" then disk = sSide pD = true
- elseif peripheral.getType(sSide[i]) == "modem" then modem = sSide pW = true
- elseif peripheral.getType(sSide[i])==nil then
- error("fail")
- local mon=term
- end
- end
- end
- --option function
- local function opt(m,mY)
- n=1
- l=#m
- while true do
- for i=1, l, 1 do
- if i==n then
- local x, y = term.getSize()
- local b = string.len(">"..m[i].."<")/2
- local x = (x/2)-b
- term.setCursorPos(x,i+mY)
- term.clearLine()
- print(">"..m[i].."<")
- else
- local x, y = term.getSize()
- b = string.len(m[i])/2
- x = (x/2)-b
- term.setCursorPos(x,i+mY)
- term.clearLine()
- print(m[i]) end
- end
- a, b= os.pullEventRaw()
- if a == "key" then
- if b==200 and n>1 then n=n-1 end
- if b==208 and n<l then n=n+1 end
- if b==28 then break end
- end
- end
- term.clear() term.setCursorPos(1,1)
- return n
- end
- -- screen functions
- local function title()
- term.clear()
- term.setCursorPos(1,1)
- print(" Welcome to Master Control initialization!")
- print(" Please read each selection carefully.")
- print(" If you mess up, press CTRL + T")
- print(" And run the wizard again.")
- term.setCursorPos(1,9)
- end
- local function newPage()
- term.clear()
- term.setCursorPos(1,1)
- print(".-----------------------------------------------.")
- print("| Welcome to Master Control |")
- print("| Ver. 1.7 |")
- print("+-----------------------------------------------+")
- term.setCursorPos(1,6)
- print(" Please select Program to run")
- term.setCursorPos(1,8)
- end
- local function nukePage()
- term.clear()
- term.setCursorPos(1,1)
- print(".-----------------------------------------------.")
- print("| Welcome to NukeOS |")
- print("| Ver. 1.7 |")
- print("+-----------------------------------------------+")
- term.setCursorPos(1,5)
- end
- local function prodPage()
- term.clear()
- term.setCursorPos(1,1)
- print(".-----------------------------------------------.")
- print("| Production Control |")
- print("| Ver. 1.7 |")
- print("+-----------------------------------------------+")
- term.setCursorPos(1,6)
- end
- local function mainPage()
- term.clear()
- term.setCursorPos(1,1)
- print(".-----------------------------------------------.")
- print("| Maintenance Access |")
- print("+-----------------------------------------------+")
- term.setCursorPos(1,6)
- print(" Please Select Function ")
- term.setCursorPos(1,8)
- end
- local function blank()
- term.setCursorPos(7,3)
- print("+--------------+ +--------------+")
- term.setCursorPos(7,4)
- print("| | | |")
- term.setCursorPos(7,5)
- print("| | | |")
- term.setCursorPos(7,6)
- print("| Press ENTER | | to Roll |")
- term.setCursorPos(7,7)
- print("| | | |")
- term.setCursorPos(7,8)
- print("| BACKSPACE | | to Exit |")
- term.setCursorPos(7,9)
- print("| | | |")
- term.setCursorPos(7,10)
- print("| | | |")
- term.setCursorPos(7,11)
- print("+--------------+ +--------------+")
- end
- local function gPage()
- term.clear()
- term.setCursorPos(1,1)
- print(" _______ _______ _______ _______ _______ ")
- print(" ( ____ \\( ___ )( )( ____ \\( ____ \\")
- print(" | ( \\/| ( ) || () () || ( \\/| ( \\/")
- print(" | | | (___) || || || || (__ | (_____ ")
- print(" | | ____ | ___ || |(_)| || __) (_____ )")
- print(" | | \\_ )| ( ) || | | || ( ) |")
- print(" | (___) || ) ( || ) ( || (____/\\/\\____) |")
- print(" (_______)|/ \\||/ \\|(_______/\\_______)")
- end
- local function sTitle()
- term.setCursorPos(1,15)
- print(" __ __ ___ ___ __ _ ___ _____ __ ")
- print(" / /' / /\\ | |_)| | \\ ( ('| | / / \\ | | ( ('")
- print(" \\_\\_,/_/--\\|_| \\|_|_/ _)_)|_|__\\_\\_/ |_| _)_)")
- end
- local function loser()
- term.clear()
- term.setCursorPos(1,5)
- print(" __ ___ __ ____ ____ ")
- print(" || // \\\\ (( \\ || || \\\\")
- print(" || (( )) \\\\ ||== ||_//")
- print(" ||__| \\\\_// \\_)) ||___ || \\\\")
- sleep(3)
- term.clear()
- end
- local function jackpot()
- for x = 1,5 do
- term.clear()
- sleep(.25)
- term.setCursorPos(1,5)
- print(" __ ___ ___ __ __ ____ ___ ______")
- print(" || // \\\\ // || // || \\\\ // \\\\ | || |")
- print(" || ||=|| (( ||<< ||_// (( )) || ")
- print(" |__|| || || \\\\__ || \\\\ || \\\\_// || ")
- sleep(.25)
- end
- end
- local function soon()
- for i = 1,5 do
- term.clear()
- term.setCursorPos(1,1)
- sleep(.25)
- print(" ) ( ) ")
- print(" ( ( /( ( )\\ ) ( /( ( ")
- print(" )\\ )\\()) )\\))( (()/( )\\()))\\ ) ")
- print(" (((_|(_)\\ ((_)()\\ /(_)|(_)\\(()/( ")
- print(" )\\___ ((_)(_()((_|_)) _((_)/(_))_ ")
- print(" ((/ __/ _ \\| \\/ |_ _|| \\| (_)) __| ")
- print(" | (_| (_) | |\\/| || | | .' | | (_ | ")
- print(" (\\___\\__)/|_| |_|__)||_|\\_| \\___| ")
- print(" ")
- print(" )\\ ) ( /( ( /( ( /( ")
- print(" (()/( )\\()) )\\()) )\\()) ")
- print(" /(_)|(_)\\ ((_)\\ ((_)\\ ")
- print(" (_)) ((_) ((_) _((_) ")
- print(" / __| / _ \\ / _ \\| \\| | ")
- print(" \\__ \\| (_) | (_) | .' | ")
- print(" |___/ \\___/ \\___/|_|\\_| ")
- sleep(.5)
- end
- end
- -- dice functions
- local function dTitle()
- term.setCursorPos(1,14)
- print(" __ __ ___ _ ")
- print(" / / __ ______/ /____ __ / _ \\(_)______ ")
- print(" / /__/ // / __/ '_/ // / / // / / __/ -_)")
- print(" /____/\\_,_/\\__/_/\\_\\\\_, / /____/_/\\__/\\__/ ")
- print(" /___/ ")
- end
- local function die1()
- local x = math.random(1,6)
- if x == 1 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 2 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 3 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 4 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 5 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 6 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- end
- end
- local function die2()
- local x = math.random(1,6)
- if x == 1 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 2 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 3 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 4 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 5 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 6 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- end
- end
- local function roll()
- local r = 1
- for r = 1,50 do
- parallel.waitForAll(die1,die2,sleep(.1))
- end
- end
- local function dice()
- while true do
- term.clear()
- dTitle()
- blank()
- event, p1 = os.pullEvent("key")
- if p1 == 28 then
- roll()
- sleep(3)
- elseif p1 == 14 then break
- end
- end
- end
- -- 8block functions
- local function bTitle()
- term.clear()
- term.setCursorPos(1,1)
- print(" _ _ _ __ __ _ ")
- print(" ' ) ) ) ( ) / ) // / ")
- print(" / / / __. _, o _. ./' /--< // __ _. /_ ")
- print(" / ' (_(_/|_(_)_<_(__ (__) /___/_</_(_)(__/ <_ ")
- print(" /| ")
- print(" |/ ")
- end
- local function ans()
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | |"..answers[math.random(1,#answers)].."| |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | '--------------' |")
- print(" '----------------' ")
- end
- local function start()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print("Ask me ANY | .--------------. | ")
- print("question, and | | ____ | | BACKSPACE ")
- print("press ENTER | | .' __ '. | | ")
- print("to receive | | | (__) | | | ")
- print("your answer... | | .'____'. | | to exit ")
- print(" | | | (____) | | | ")
- print(" | | '.______.' | | ")
- print(" | | | | ")
- print(" | '--------------' | ")
- print(" '----------------' ")
- end
- local function shake()
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. | * ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" * | '--------------' | ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" * .----------------. ")
- print(" | .--------------. | ")
- print(" | | | | * * ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | '--------------' | ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | * ")
- print(" * | '--------------' | * ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * * | | | | * ")
- print(" | '--------------' | ")
- print(" '----------------' * ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * * | | | | ")
- print(" | | | | * ")
- print(" | '--------------' | ")
- print(" * '----------------' * ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | '--------------' |")
- print(" '----------------' ")
- sleep(1.5)
- ans()
- end
- local function block()
- start()
- while true do
- local event, p1 = os.pullEvent("key")
- if p1 == 28 then
- shake()
- sleep(2)
- start()
- elseif p1 == 14 then break
- end
- end
- end
- -- slots functions
- local function cardtop(x,y)
- term.setCursorPos(x,y)
- write([[ .------------. ]])
- term.setCursorPos(x,y+1)
- write([[| .----------. |]])
- term.setCursorPos(x,y+2)
- write([[| | | |]])
- term.setCursorPos(x,y+3)
- write([[| | .------. | |]])
- term.setCursorPos(x,y+4)
- end
- local function cardbase(x,y)
- term.setCursorPos(x,y+8)
- write([[| | '------' | |]])
- term.setCursorPos(x,y+9)
- write([[| | | |]])
- term.setCursorPos(x,y+10)
- write([[| '----------' |]])
- term.setCursorPos(x,y+11)
- write([[ '------------' ]])
- end
- local function numtop(n,x,y)
- if symbol[n] == "10" then
- term.setCursorPos(x,y+4)
- write([[| | |]]..symbol[n]..[[--. | | |]])
- else
- term.setCursorPos(x,y+4)
- write([[| | |]]..symbol[n]..[[.--. | | |]])
- end
- end
- local function numbase(n,x,y)
- if symbol[n] == "10" then
- term.setCursorPos(x,y+7)
- write([[| | | '--]]..symbol[n]..[[| | |]])
- else
- term.setCursorPos(x,y+7)
- write([[| | | '--']]..symbol[n]..[[| | |]])
- end
- end
- local function spade(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | (__) | | |]])
- end
- local function heart(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | (\/) | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- local function club(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :(): | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | ()() | | |]])
- end
- local function diamond(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- local function slot(pos)
- local c = math.random(1,4)
- local n = math.random(1,13)
- cardtop(pos,1)
- numtop(n,pos,1)
- if c == 1 then
- spade(pos,1)
- elseif c == 2 then
- heart(pos,1)
- elseif c == 3 then
- club(pos,1)
- elseif c == 4 then
- diamond(pos,1)
- end
- numbase(n,pos,1)
- cardbase(pos,1)
- return c,n
- end
- local function spin()
- for cnt = 1, 10 do
- slot(2)
- slot(18)
- slot(34)
- sleep(cnt/30)
- end
- end
- local function allsuitsmatch(result)
- return (result[1] == result[3] and result[3] == result[5] and result[5] ==result[1])
- end
- local function allvaluesmatch(result)
- return (result[2] == result[4] and result[4] == result[6] and result[6] ==result[2] )
- end
- local function isroyalflush(result)
- local Fresult = false
- if result[2] > 10 and result[4] > 10 and result[6] > 10 then
- if result[2] ~= result[4] and result[4] ~= result[6] and result[6] ~= result[2] then return true -- royal flush discounting Ace
- end
- end
- if result[2] == 1 and result[4] > 11 and result[6] > 11 and result[4] ~= result[6] then return true --royal flush including ace, condition 1
- elseif result[4] == 1 and result[6] > 11 and result[2] > 11 and result[6] ~= result[2] then return true --royal flush including ace, condition 2
- elseif result[6] == 1 and result[2] > 11 and result[4] > 11 and result[2] ~= result[4] then return true --royal flush including ace, condition 3
- end
- return false
- end
- local function testwin(results)
- ------------------------------
- -- This function has been --
- -- brought to you by Pharap --
- ------------------------------
- local value = 0
- if allsuitsmatch(results) then value = 1 end -- suits match
- if allvaluesmatch(results) then value = 2 end -- values match
- if allsuitsmatch(results) and allvaluesmatch(results) then value = 3 end --suits and values match
- if isroyalflush(results) then value = 4 end -- royal flush
- if isroyalflush(results) and allsuitsmatch(results) then value = 5 end -- royal flush of all matching suits
- if isroyalflush(results) and allvaluesmatch(results) then value = "wtfiswrongwithyou,howthehelldidyoucausesuchabloodystupiderror" return "error" end-- lol, like this would actually happen
- return value
- end
- local function slots()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- while true do
- local event, p1 = os.pullEvent()
- if event == "key" then
- if p1 == 28 then
- spin()
- local s1, n1 = slot(2)
- local s2, n2 = slot(18)
- local s3, n3 = slot(34)
- sleep(2)
- local results = {s1,n1,s2,n2,s3,n3}
- --local results = {3,1,3,12,3,13}
- local condition = testwin(results)
- if condition == 0 then
- loser()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 1 then --suits
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 2 then --values
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 3 then --suits and values
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 4 then --royal flush
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 5 then --royal flush suited
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- end
- elseif p1 == 14 then break
- end
- end
- end
- end
- -- game functions
- local function games()
- while true do
- gPage()
- local input = opt(gMenu,10)
- if input == 1 then
- dice()
- elseif input == 2 then
- block()
- elseif input == 3 then
- slots()
- elseif input == 4 then break
- end
- end
- end
- -- action functions
- local function time()
- while pM do
- local mX,mY = mon.getSize()
- local t = os.time()
- time = textutils.formatTime(t,false)
- mon.setCursorPos(mX-9,3)
- mon.write(time)
- sleep(0)
- end
- end
- local function saveState(saveTable)
- local file = fs.open("status", "w")
- if file then
- for eNum, eInfo in ipairs(saveTable) do
- file.writeLine(eInfo.type..","..eInfo.color..","..eInfo.status)
- end
- file.close()
- end
- end
- local function loadState()
- local loadTable = {}
- local file = fs.open("status", "r")
- if file then
- readLine = file.readLine()
- while readLine do
- local lineTable = {}
- lineTable.type, lineTable.color, lineTable.status = string.match(readLine, "(%w+),(%w+),(%w+)")
- if lineTable.type then
- table.insert(loadTable, lineTable)
- end
- readLine = file.readLine()
- end
- file.close()
- end
- return loadTable
- end
- local function menuOpt()
- local btn1 = {1,1,menu[1]}
- local btn2 = {2,1,menu[2]}
- local btn3 = {1,2,menu[3]}
- local btn4 = {2,2,menu[4]}
- local btn5 = {1,3,menu[5]}
- local btn6 = {2,3,menu[6]}
- local a1 = string.len(" ["..btn1[3].."] "..btn2[3].." ")/2
- local a2 = string.len(" "..btn1[3].." ["..btn2[3].."]")/2
- local a3 = string.len(" "..btn1[3].." "..btn2[3].." ")/2
- local b1 = string.len(" ["..btn3[3].."] "..btn4[3].." ")/2
- local b2 = string.len(" "..btn3[3].." ["..btn4[3].."]")/2
- local b3 = string.len(" "..btn3[3].." "..btn4[3].." ")/2
- local c1 = string.len(" ["..btn5[3].."] "..btn6[3].." ")/2
- local c2 = string.len(" "..btn5[3].." ["..btn6[3].."]")/2
- local c3 = string.len(" "..btn5[3].." "..btn6[3].." ")/2
- local x,y = term.getSize()
- local curx=btn1[1]
- local cury=btn1[2]
- while true do
- --test for looping
- if curx<btn1[1] and cury==btn1[2] then curx=btn2[1] cury=btn2[2]
- elseif curx>btn2[1] and cury==btn2[2] then curx=btn1[1] cury=btn1[2]
- elseif curx<btn3[1] and cury==btn3[2] then curx=btn4[1] cury=btn4[2]
- elseif curx>btn4[1] and cury==btn4[2] then curx=btn3[1] cury=btn3[2]
- elseif curx<btn5[1] and cury==btn5[2] then curx=btn6[1] cury=btn6[2]
- elseif curx>btn6[1] and cury==btn6[2] then curx=btn5[1] cury=btn5[2]
- elseif cury<btn1[2] and curx==btn1[1] then cury=btn5[2] curx=btn5[1]
- elseif cury>btn5[2] and curx==btn5[1] then cury=btn1[2] curx=btn1[1]
- elseif cury<btn2[2] and curx==btn2[1] then cury=btn6[2] curx=btn6[1]
- elseif cury>btn6[2] and curx==btn6[1] then cury=btn2[2] curx=btn2[1]
- end
- -- line 1 of options
- if curx==btn1[1] and cury==btn1[2] then
- local x = (x/2)-a1
- term.setCursorPos(x,8)
- print(" ["..btn1[3].."] "..btn2[3].." ")
- elseif curx==btn2[1] and cury==btn2[2] then
- local x = (x/2)-a2
- term.setCursorPos(x,8)
- print(" "..btn1[3].." ["..btn2[3].."]")
- else
- local x = (x/2)-a3
- term.setCursorPos(x,8)
- print(" "..btn1[3].." "..btn2[3].." ")
- end
- -- line 2 of options
- if curx==btn3[1] and cury==btn3[2] then
- local x = (x/2)-b1
- term.setCursorPos(x,10)
- print(" ["..btn3[3].."] "..btn4[3].." ")
- elseif curx==btn4[1] and cury==btn4[2] then
- local x = (x/2)-b2
- term.setCursorPos(x,10)
- print(" "..btn3[3].." ["..btn4[3].."]")
- else
- local x = (x/2)-b3
- term.setCursorPos(x,10)
- print(" "..btn3[3].." "..btn4[3].." ")
- end
- -- line 3 of options
- if curx==btn5[1] and cury==btn5[2] then
- local x = (x/2)-c1
- term.setCursorPos(x,12)
- print(" ["..btn5[3].."] "..btn6[3].." ")
- elseif curx==btn6[1] and cury==btn6[2] then
- local x = (x/2)-c2
- term.setCursorPos(x,12)
- print(" "..btn5[3].." ["..btn6[3].."]")
- else
- local x = (x/2)-c3
- term.setCursorPos(x,12)
- print(" "..btn5[3].." "..btn6[3].." ")
- end
- e, k = os.pullEvent("key")
- if k==203 then curx = curx - 1 --left
- elseif k==205 then curx = curx + 1 --right
- elseif k==200 then cury = cury - 1 --up
- elseif k==208 then cury = cury + 1 --down
- elseif k==28 then break --enter
- end
- end
- if curx == 1 and cury == 1 then return "1" end
- if curx == 2 and cury == 1 then return "2" end
- if curx == 1 and cury == 2 then return "3" end
- if curx == 2 and cury == 2 then return "4" end
- if curx == 1 and cury == 3 then return "5" end
- if curx == 2 and cury == 3 then return "6" end
- end
- local function yN()
- local n=1
- while true do
- local x, y=term.getCursorPos()
- term.clearLine()
- if n==1 then write(">YES< NO") else write (" YES >NO<") end
- term.setCursorPos(x, y)
- a, b=os.pullEvent()
- while a~="key" do a, b=os.pullEvent() end
- if b==203 and n==2 then n=1 end
- if b==205 and n==1 then n=2 end
- if b==28 then print("") break end
- end
- if n==1 then return "true" end
- if n==2 then return "false" end
- return false
- end
- local function login()
- while true do
- newPage()
- term.setCursorPos(1,6)
- term.clearLine()
- print("Please enter User ID:")
- local user = read()
- controlTable = loadState()
- for eNum,dInfo in ipairs(controlTable) do
- if dInfo.type == "Admin" and user == dInfo.color then
- newPage()
- term.setCursorPos(1,6)
- term.clearLine()
- print("Please enter User password:")
- local pass = read("*")
- if dInfo.type == "Admin" and pass == dInfo.status then
- return admin,true
- end break
- elseif dInfo.type == "User" and user == dInfo.color then
- newPage()
- term.setCursorPos(1,6)
- term.clearLine()
- print("Please enter User password:")
- local pass = read("*")
- if dInfo.type == "User" and pass == dInfo.status then
- return user,true
- end break
- end
- end
- end
- end
- local function colorConvert(color)
- if color > 1 then return 2^(color - 2)
- else return "redstone"
- end
- end
- local function firstRun()
- if fs.exists("status") then fs.delete("status") end
- --temporary save file
- local deviceTable = {type="Admin"}
- deviceTable.color = "admin_name_temp"
- deviceTable.status = "admin_pass_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="User"}
- deviceTable.color = "user_name_temp"
- deviceTable.status = "user_pass_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Lights"}
- deviceTable.color = "lights_color_temp"
- deviceTable.status = "lights_color_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Industrialcraft2"}
- deviceTable.color = "ic2_control_temp"
- deviceTable.status = "ic2_exists_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="IC2Power"}
- deviceTable.color = "power_color_temp"
- deviceTable.status = "power_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.color = "reactor_color_temp"
- deviceTable.status = "reactor_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.color = "cool_color_temp"
- deviceTable.status = "cool_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="EnergyStorage"}
- deviceTable.color = "energy_color_temp"
- deviceTable.status = "energy_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Macerator"}
- deviceTable.color = "macerator_color_temp"
- deviceTable.status = "macerator_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Furnace"}
- deviceTable.color = "furnace_color_temp"
- deviceTable.status = "furnace_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Compressor"}
- deviceTable.color = "compressor_color_temp"
- deviceTable.status = "compressor_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Extractor"}
- deviceTable.color = "extractor_color_temp"
- deviceTable.status = "extractor_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="RedPower2"}
- deviceTable.color = "rp2_control_temp"
- deviceTable.status = "rp2_exists_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="RedPowerPump"}
- deviceTable.color = "rp2pump_color_temp"
- deviceTable.status = "rp2pump_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Blockbreaker"}
- deviceTable.color = "breaker_color_temp"
- deviceTable.status = "breaker_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Buildcraft"}
- deviceTable.color = "bc_control_temp"
- deviceTable.status = "bc_exists_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="MiningWell"}
- deviceTable.color = "miningwell_color_temp"
- deviceTable.status = "miningwell_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Quarry"}
- deviceTable.color = "quarry_color_temp"
- deviceTable.status = "quarry_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="BuildcraftPump"}
- deviceTable.color = "bcpump_color_temp"
- deviceTable.status = "bcpump_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Forcefield"}
- deviceTable.color = "field_color_temp"
- deviceTable.status = "field_status_temp"
- table.insert(controlTable,deviceTable)
- saveState(controlTable)
- --run system
- while true do
- title()
- local deviceTable = {type="Admin"}
- while true do
- print("Please enter Administrator name:")
- deviceTable.color = read()
- if deviceTable.color == "" then
- print("Admin name cannot be blank")
- sleep(1)
- title()
- else break
- end
- end
- title()
- while true do
- while true do
- print("Please enter Administrator password:")
- tempadmin = read("*")
- if tempadmin == "" then
- print("Password cannot be blank")
- sleep(1)
- title()
- else break
- end
- end
- title()
- while true do
- print("Please re-enter password:")
- tempadmin2 = read("*")
- if tempadmin2 == "" then
- print("Password cannot be blank")
- sleep(1)
- title()
- else break
- end
- end
- title()
- if tempadmin ~= tempadmin2 then
- print("Passwords do not match. Please try again.")
- sleep(1)
- title()
- elseif tempadmin == tempadmin2 then
- deviceTable.status = tempadmin break
- end
- end
- title()
- print("Thank you. Admin profile created.")
- sleep(1)
- table.insert(controlTable,1,deviceTable)
- table.remove(controlTable,2,deviceTable)
- saveState(controlTable)
- tempadmin = nil
- tempadmin2 = nil
- break
- end
- local deviceTable = {type="User"}
- while true do
- title()
- print("Please enter User name:")
- tempusername = read()
- if tempusername == adminname then
- print("Cannot have User name the same as Administrator name.")
- sleep(1)
- title()
- elseif tempusername == "" then
- print("User name cannot be blank.")
- sleep(1)
- title()
- else
- deviceTable.color = tempusername
- break
- end
- end
- while true do
- title()
- while true do
- while true do
- print("Please enter User password:")
- tempuser = read("*")
- if tempuser == "" then
- print("Password cannot be blank.")
- sleep(1)
- title()
- else break
- end
- end
- title()
- while true do
- title()
- print("Pleas re-enter password:")
- tempuser2 = read("*")
- if tempuser2 == "" then
- print("Password cannot be blank.")
- sleep(1)
- title()
- else break
- end
- end
- title()
- if tempuser ~= tempuser2 then
- print("Passwords do not match. Please try again.")
- sleep(1)
- title()
- elseif tempuser == tempuser2 then
- deviceTable.status = tempuser break
- end
- end
- title()
- print("Thank you. User profile created.")
- sleep(1)
- break
- end
- table.insert(controlTable,2,deviceTable)
- table.remove(controlTable,3,devicetable)
- saveState(controlTable)
- tempusername = nil
- tempuser = nil
- tempuser2 = nil
- local deviceTable = {type="Lights"}
- title()
- print("Do you have lighting that you want to control?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- --deviceTable.type = "Lights"
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,3,deviceTable)
- table.remove(controlTable,4,devicetable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,3,deviceTable)
- table.remove(controlTable,4,devicetable)
- saveState(controlTable)
- end
- title()
- --determine mods
- while true do
- print("What mods do you have?")
- print("Please indicate ALL mods installed.")
- sleep(2)
- title()
- local mods = opt(modslist,9)
- if mods == 1 then --IndustrialCraft2
- local modTable = {type="IndustrialCraft2"}
- modTable.status = "true"
- title()
- print("Do you want to control this mod?")
- local input = yN()
- if input == "true" then
- modTable.color = "true"
- table.insert(controlTable,4,modTable)
- table.remove(controlTable,5,devicetable)
- saveState(controlTable)
- title()
- print("What type of power are you using?")
- deviceTable.type = tostring(opt(IC2power,7))
- if deviceTable.type == "7" then
- deviceTable.type = "Power"
- deviceTable.color = "false"
- deviceTable.status = "false"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- title()
- print("Do you want this computer to control your reactor?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- else
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Coolant"}
- deviceTable.type = "Coolant"
- title()
- print("Do you have an independant coolant system?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- else
- deviceTable.status = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- end
- elseif deviceTable.type == "1" then
- local deviceTable = {type="NoIC2Power"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "2" then
- deviceTable.type = "Generator"
- deviceTable.color = "none"
- deviceTable.status = "none"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type =="3" then
- deviceTable.type = "Geothermal"
- deviceTable.color = "none"
- deviceTable.status = "none"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "4" then
- deviceTable.type = "WaterMill"
- deviceTable.color = "none"
- deviceTable.status = "none"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "5" then
- deviceTable.type = "WindMill"
- deviceTable.color = "none"
- deviceTable.status = "none"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "6" then
- deviceTable.type = "SolarPanel"
- deviceTable.color = "none"
- deviceTable.status = "none"
- table.insert(controlTable,5,deviceTable)
- table.remove(controlTable,6,devicetable)
- saveState(controlTable)
- local deviceTable = {type="Reactor"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- local deviceTable = {type="Coolant"}
- deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="EnergyStorage"}
- title()
- print("What type of energy storage are you using?")
- sleep(2)
- deviceTable.type = tostring(opt(eType,7))
- if deviceTable.type == "1" then
- deviceTable.color = "false"
- deviceTable.status = "false"
- table.insert(controlTable,8,deviceTable)
- table.remove(controlTable,9,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "2" then
- deviceTable.type = "BatBox"
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "None"
- table.insert(controlTable,8,deviceTable)
- table.remove(controlTable,9,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "3" then
- deviceTable.type = "MFE"
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "None"
- table.insert(controlTable,8,deviceTable)
- table.remove(controlTable,9,deviceTable)
- saveState(controlTable)
- elseif deviceTable.type == "4" then
- deviceTable.type = "MFSU"
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "None"
- table.insert(controlTable,8,deviceTable)
- table.remove(controlTable,9,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Macerator"}
- title()
- print("Would you like to control a Macerator?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,9,deviceTable)
- table.remove(controlTable,10,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,9,deviceTable)
- table.remove(controlTable,10,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Furnace"}
- title()
- print("Would you like to control an IC2 Furnace?")
- furnace = yN()
- if furnace == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,10,deviceTable)
- table.remove(controlTable,11,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,10,deviceTable)
- table.remove(controlTable,11,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Compressor"}
- title()
- print("Would you like to control an IC2 Compressor?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,11,deviceTable)
- table.remove(controlTable,12,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,11,deviceTable)
- table.remove(controlTable,12,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Extractor"}
- title()
- print("Would you like to control an IC2 Extractor?")
- extractor = yN()
- if extractor == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,12,deviceTable)
- table.remove(controlTable,13,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,12,deviceTable)
- table.remove(controlTable,13,deviceTable)
- saveState(controlTable)
- end
- else
- modTable.color = "false"
- table.insert(controlTable,4,modTable)
- table.remove(controlTable,5,devicetable)
- saveState(controlTable)
- end
- elseif mods == 2 then --RedPower2
- local modTable = {type="RedPower2"}
- modTable.status = "true"
- title()
- print("Do you want to control this mod?")
- local input = yN()
- if input == "true" then
- modTable.color = "true"
- table.insert(controlTable,13,modTable)
- table.remove(controlTable,14,modTable)
- saveState(controlTable)
- local deviceTable = {type="RedPowerPump"}
- title()
- print("Would you like to control a RedPower pump?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,14,deviceTable)
- table.remove(controlTable,15,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,14,deviceTable)
- table.remove(controlTable,15,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Blockbreaker"}
- title()
- print("Would you like to control a RedPower Blockbreaker array?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,15,deviceTable)
- table.remove(controlTable,16,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,15,deviceTable)
- table.remove(controlTable,16,deviceTable)
- saveState(controlTable)
- end
- else
- modTable.color = "false"
- table.insert(controlTable,13,modTable)
- table.remove(controlTable,14,modTable)
- saveState(controlTable)
- end
- elseif mods == 3 then --Buildcraft
- local modTable = {type="Buildcraft"}
- modTable.status = "true"
- title()
- print("Do you want to control this mod?")
- local input = yN()
- if input == "true" then
- modTable.color = "true"
- table.insert(controlTable,16,modTable)
- table.remove(controlTable,17,modTable)
- saveState(controlTable)
- --add for engines
- local deviceTable = {type="MiningWell"}
- title()
- print("Would you like to control a Mining Well?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,17,deviceTable)
- table.remove(controlTable,18,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,17,deviceTable)
- table.remove(controlTable,18,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="Quarry"}
- title()
- print("Would you like to control a Quarry?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,18,deviceTable)
- table.remove(controlTable,19,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,18,deviceTable)
- table.remove(controlTable,19,deviceTable)
- saveState(controlTable)
- end
- local deviceTable = {type="BuildcraftPump"}
- title()
- print("Would you like to control a Buildcraft pump?")
- deviceTable.status = yN()
- if deviceTable.status == "true" then
- term.clear()
- term.setCursorPos(1,9)
- print(" What color are you using?")
- sleep(1.5)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,19,deviceTable)
- table.remove(controlTable,20,deviceTable)
- saveState(controlTable)
- else deviceTable.status = "false"
- deviceTable.color = "false"
- table.insert(controlTable,19,deviceTable)
- table.remove(controlTable,20,deviceTable)
- saveState(controlTable)
- end
- else
- modTable.color = "false"
- table.insert(controlTable,16,modTable)
- table.remove(controlTable,17,modTable)
- saveState(controlTable)
- end
- elseif mods == 4 then --Immibis' Forcefields
- local modTable = {type="Forcefield"}
- modTable.status = "true"
- title()
- print("Do you want to control this mod?")
- local input = yN()
- if input == "true" then
- modTable.color = "true"
- table.insert(controlTable,20,modTable)
- table.remove(controlTable,21,modTable)
- saveState(controlTable)
- title()
- print(" What color are you using?")
- sleep(2)
- deviceTable.color = colorConvert(opt(colorOpt,0))
- deviceTable.status = "false"
- table.insert(controlTable,21,deviceTable)
- table.remove(controlTable,22,deviceTable)
- saveState(controlTable)
- else
- modTable.color = "false"
- table.insert(controlTable,20,modTable)
- table.remove(controlTable,21,modTable)
- saveState(controlTable)
- end
- end
- title()
- print("Do you have any other Mods installed?")
- local input = yN()
- if input == "false" then break end
- end
- local deviceTable = {type="Firstrun"}
- deviceTable.color = "completed"
- deviceTable.status = "true"
- table.insert(controlTable,21,deviceTable)
- saveState(controlTable)
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("Thank you. You will now be redirected.")
- sleep(1.5)
- end
- local function toColor(c)
- if c == "false" then return "None"
- elseif c == "redstone" then return "Redstone"
- elseif c == "1" then return "White"
- elseif c == "2" then return "Orange"
- elseif c == "4" then return "Magenta"
- elseif c == "8" then return "Light Blue"
- elseif c == "16" then return "Yellow"
- elseif c == "32" then return "Lime"
- elseif c == "64" then return "Pink"
- elseif c == "128" then return "Gray"
- elseif c == "256" then return "Light Gray"
- elseif c == "512" then return "Cyan"
- elseif c == "1024" then return "Purple"
- elseif c == "2048" then return "Blue"
- elseif c == "4096" then return "Brown"
- elseif c == "8192" then return "Green"
- elseif c == "16384" then return "Red"
- elseif c == "32768" then return "Black"
- else return "test"
- end
- end
- local function systemScreen()
- mainPage()
- term.setCursorPos(1,6)
- term.clearLine()
- term.setCursorPos(1,4)
- print("| System Status |")
- print("+-----------------------------------------------+")
- end
- local function system()
- local controlTable = loadState()
- for dNum, dInfo in ipairs(controlTable) do
- if dInfo.type == "Admin" then
- systemScreen()
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowWrite(dInfo.color)
- textutils.slowWrite(", ")
- sleep(.25)
- textutils.slowPrint("*****")
- sleep(.25)
- elseif dInfo.type == "User" then
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowWrite(dInfo.color)
- textutils.slowWrite(", ")
- sleep(.25)
- textutils.slowPrint("*****")
- sleep(.25)
- elseif dInfo.type == "Firstrun" then
- systemScreen()
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(" ")
- sleep(.25)
- textutils.slowWrite(dInfo.color)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowPrint(dInfo.status)
- elseif dInfo.type == "IndustrialCraft2" or dInfo.type == "RedPower2" or dInfo.type == "Buildcraft" then
- systemScreen()
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowPrint(dInfo.status)
- sleep(.25)
- elseif dInfo.type == "Forcefield" then
- systemScreen()
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowWrite(toColor(dInfo.color))
- textutils.slowWrite(", ")
- sleep(.25)
- textutils.slowPrint(dInfo.status)
- sleep(.25)
- else
- textutils.slowWrite(dInfo.type)
- textutils.slowWrite(": ")
- sleep(.25)
- textutils.slowWrite(toColor(dInfo.color))
- textutils.slowWrite(", ")
- sleep(.25)
- textutils.slowPrint(dInfo.status)
- sleep(.25)
- end
- end
- while true do
- term.setCursorPos(31,13)
- write(".----------------.")
- term.setCursorPos(31,14)
- write("| Press OK to |")
- term.setCursorPos(31,15)
- write("| continue |")
- term.setCursorPos(31,16)
- write("| |")
- term.setCursorPos(31,17)
- write("+------[OK]------+")
- event, p1 = os.pullEvent("key")
- if p1 == 28 then
- break
- end
- end
- end
- local function resume()
- controlTable = loadState()
- local colorVar = 0
- for eNum, dInfo in ipairs(controlTable) do
- for i = 1,#machineList do
- if dInfo.type == machineList[i] then
- if dInfo.type == "Reactor" or dInfo.type == "Coolant" then
- if dInfo.status == "false" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
- colorVar = colorVar + tonumber(dInfo.color)
- elseif dInfo.status == "true" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
- colorVar = colorVar + 0
- end
- else
- if dInfo.status == "false" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
- colorVar = colorVar + 0
- elseif dInfo.status == "true" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
- colorVar = colorVar + tonumber(dInfo.color)
- end
- end
- end
- end
- end
- rs.setBundledOutput("back",colorVar)
- end
- --monitor actions
- local function MCscreen()
- if pM then
- local mX,mY = mon.getSize()
- mon.clear()
- mon.setCursorPos(1,1)
- for i=1,mX do
- mon.setCursorPos(i,1)
- mon.write("-")
- mon.setCursorPos(i,mY)
- mon.write("-")
- mon.setCursorPos(i,5)
- mon.write("-")
- mon.setCursorPos(i,7)
- mon.write("-")
- end
- for i=1,mY do
- mon.setCursorPos(1,i)
- mon.write("|")
- mon.setCursorPos(mX,i)
- mon.write("|")
- end
- for i=6,mY-1 do
- mon.setCursorPos(25,i)
- mon.write("|")
- mon.setCursorPos(50,i)
- mon.write("|")
- end
- for i=2,mX do
- mon.setCursorPos(i,16)
- mon.write("-")
- mon.setCursorPos(i,18)
- mon.write("-")
- end
- mon.setCursorPos(1,1)
- mon.write(".")
- mon.setCursorPos(mX,1)
- mon.write(".")
- mon.setCursorPos(1,5)
- mon.write("+")
- mon.setCursorPos(mX,5)
- mon.write("+")
- mon.setCursorPos(1,7)
- mon.write("+")
- mon.setCursorPos(mX,7)
- mon.write("+")
- mon.setCursorPos(1,mY)
- mon.write("'")
- mon.setCursorPos(mX,mY)
- mon.write("'")
- mon.setCursorPos(25,5)
- mon.write("+")
- mon.setCursorPos(50,5)
- mon.write("+")
- mon.setCursorPos(25,7)
- mon.write("+")
- mon.setCursorPos(50,7)
- mon.write("+")
- mon.setCursorPos(25,mY)
- mon.write("+")
- mon.setCursorPos(50,mY)
- mon.write("+")
- mon.setCursorPos(1,16)
- mon.write("+")
- mon.setCursorPos(mX,16)
- mon.write("+")
- mon.setCursorPos(25,16)
- mon.write("+")
- mon.setCursorPos(50,16)
- mon.write("+")
- mon.setCursorPos(1,18)
- mon.write("+")
- mon.setCursorPos(mX,18)
- mon.write("+")
- mon.setCursorPos(25,18)
- mon.write("+")
- mon.setCursorPos(50,18)
- mon.write("+")
- local b = string.len("Master Control System Status")/2
- local x = (mX/2)-b
- mon.setCursorPos(x,3)
- mon.write("Master Control System Status")
- end
- end
- local function mStatus(x)
- local controlTable = loadState()
- if x=="true" then state="On"
- elseif x=="false" then state="Off"
- end
- return state
- end
- local function monTitle()
- while true do
- mon.clear()
- MCscreen()
- local controlTable = loadState()
- for eNum,dInfo in ipairs(controlTable) do
- if dInfo.type~="Admin" and dInfo.type~="User" and dInfo.type~="Firstrun" then
- mon.setCursorPos(5,6)
- mon.write("IndustrialCraft")
- if dInfo.type=="Macerator" then
- mon.setCursorPos(3,8)
- mon.write("Macerator: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type=="Furnace" then
- mon.setCursorPos(3,10)
- mon.write("Furnace: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type=="Compressor" then
- mon.setCursorPos(3,12)
- mon.write("Compressor: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type=="Extractor" then
- mon.setCursorPos(3,14)
- mon.write("Extractor: ")
- mon.write(mStatus(dInfo.status))
- end
- mon.setCursorPos(33,6)
- mon.write("Buildcraft")
- if dInfo.type == "MiningWell" then
- mon.setCursorPos(27,8)
- mon.write("Mining Well: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type == "Quarry" then
- mon.setCursorPos(27,10)
- mon.write("Quarry: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type == "BuildcraftPump" then
- mon.setCursorPos(27,12)
- mon.write("BC2 Pump: ")
- mon.write(mStatus(dInfo.status))
- end
- mon.setCursorPos(59,6)
- mon.write("RedPower")
- if dInfo.type == "RedPowerPump" then
- mon.setCursorPos(52,8)
- mon.write("RedPower Pump: ")
- mon.write(mStatus(dInfo.status))
- elseif dInfo.type == "Blockbreaker" then
- mon.setCursorPos(52,10)
- mon.write("Blockbreakers: ")
- mon.write(mStatus(dInfo.status))
- end
- mon.setCursorPos(2,17)
- mon.write("IndustrialCraft Power")
- if dInfo.type=="MFSU" or dInfo.type == "Batbox" or dInfo.type == "MFE"then
- mon.setCursorPos(3,19)
- mon.write(dInfo.type..": ")
- mon.write(dInfo.status)
- elseif dInfo.type=="Reactor" and dInfo.color~="false" then
- mon.setCursorPos(3,23)
- mon.write("Reactor: ")
- mon.write(mStatus(dInfo.status))
- mon.setCursorPos(3,25)
- mon.write("Coolant: ")
- mon.write(mStatus(dInfo.status))
- end
- mon.setCursorPos(30,17)
- mon.write("Buildcraft Power")
- for i = 1,#BCpower do
- if dInfo.type == pTypeX[i] then
- mon.setCursorPos(27,19)
- mon.write(dInfo.type..": ")
- mon.write(mStatus(dInfo.status))
- end
- end
- mon.setCursorPos(57,17)
- mon.write("Forcefield")
- if dInfo.type == "Forcefield" then
- mon.setCursorPos(52,19)
- mon.write("Forcefield: ")
- mon.write(mStatus(dInfo.status))
- end
- end
- end
- sleep(1)
- end
- end
- local function MCtime()
- while pM do
- local mX,mY = mon.getSize()
- local t = os.time()
- time = textutils.formatTime(t,false)
- mon.setCursorPos(mX-9,3)
- mon.write(time)
- sleep(0)
- end
- end
- --main code
- local function MCS()
- if not fs.exists("status") then
- term.clear()
- firstRun()
- end
- local user,pass = login()
- while true do
- newPage()
- resume()
- controlTable = loadState()
- for eNum, dInfo in ipairs(controlTable) do
- if dInfo.type == "Firstrun" then
- if dInfo.status == "false" then
- firstRun()
- elseif dInfo.status == nil then
- firstRun()
- end
- end
- end
- local option = menuOpt()
- if option == "1" then --production started
- while true do
- prodPage()
- local input = opt(pMenu,5)
- if input == 1 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Macerator" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,9,deviceTable)
- table.remove(controlTable,10,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,9,deviceTable)
- table.remove(controlTable,10,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 2 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Furnace" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,10,deviceTable)
- table.remove(controlTable,11,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,10,deviceTable)
- table.remove(controlTable,11,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 3 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Compressor" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,11,deviceTable)
- table.remove(controlTable,12,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,11,deviceTable)
- table.remove(controlTable,12,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 4 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Extractor" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,12,deviceTable)
- table.remove(controlTable,13,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,12,deviceTable)
- table.remove(controlTable,13,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 5 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "RedPowerPump" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,14,deviceTable)
- table.remove(controlTable,15,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,14,deviceTable)
- table.remove(controlTable,15,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 6 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Blockbreaker" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,15,deviceTable)
- table.remove(controlTable,16,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,15,deviceTable)
- table.remove(controlTable,16,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 7 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "MiningWell" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,17,deviceTable)
- table.remove(controlTable,18,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,17,deviceTable)
- table.remove(controlTable,18,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 8 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Quarry" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,18,deviceTable)
- table.remove(controlTable,19,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,18,deviceTable)
- table.remove(controlTable,19,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 9 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "BuildcraftPump" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,19,deviceTable)
- table.remove(controlTable,20,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,19,deviceTable)
- table.remove(controlTable,20,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 10 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Forcefield" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,20,deviceTable)
- table.remove(controlTable,21,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,20,deviceTable)
- table.remove(controlTable,21,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 11 then break
- end
- end
- elseif option == "2" then --reactor control
- if user == admin and pass == true then
- while true do
- nukePage()
- local input = opt(rMenu,7)
- if input == 1 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Reactor" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- end
- elseif deviceTable.type == "Coolant" then
- if deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 2 then
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Reactor" then
- if deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,6,deviceTable)
- table.remove(controlTable,7,deviceTable)
- saveState(controlTable)
- end
- elseif deviceTable.type == "Coolant" then
- if deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,7,deviceTable)
- table.remove(controlTable,8,deviceTable)
- saveState(controlTable)
- end
- end
- end
- elseif input == 3 then break
- end
- end
- else
- term.clear()
- term.setCursorPos(1,10)
- print(" You must be Admin level to use the reactor ")
- sleep(1)
- end
- elseif option == "3" then --lights
- controlTable = loadState()
- for dNum, deviceTable in ipairs(controlTable) do
- if deviceTable.type == "Lights" then
- if deviceTable.status == "true" then
- rs.setBundledOutput("back", colors.subtract(tonumber(deviceTable.color)))
- deviceTable.status = "false"
- table.insert(controlTable,3,deviceTable)
- table.remove(controlTable,4,deviceTable)
- saveState(controlTable)
- elseif deviceTable.status == "false" then
- rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
- deviceTable.status = "true"
- table.insert(controlTable,3,deviceTable)
- table.remove(controlTable,4,deviceTable)
- saveState(controlTable)
- end break
- end
- end
- elseif option == "4" then --maintenance
- while true do
- mainPage()
- local input = opt(mMenu,7)
- if input == 1 then
- system()
- elseif input == 2 then
- if user == admin and pass == true then
- local controlTable = loadState()
- firstRun()
- else
- term.clear()
- term.setCursorPos(1,10)
- print(" You must be Admin level to run Initialization ")
- sleep(1.5)
- end
- elseif input == 3 then break
- end
- end
- elseif option == "5" then --games
- games()
- elseif option == "6" then os.shutdown()
- end
- end
- end
- --parallel
- if pM then
- parallel.waitForAll(MCS,monTitle,MCtime)
- else
- MCS()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement