Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("space.nfp") then
- oFile = fs.open("space.nfp", "w")
- oFile.writeLine(" 000000")
- oFile.writeLine(" 00 00")
- oFile.writeLine("000 00")
- oFile.flush()
- oFile.close()
- end
- if not fs.exists("dial.nfp") then
- oFile = fs.open("dial.nfp", "w")
- oFile.writeLine(" 777 ")
- oFile.writeLine("77777")
- oFile.writeLine("77777")
- oFile.writeLine(" 777 ")
- oFile.flush()
- oFile.close()
- end
- if not fs.exists("buttonOn.nfp") then
- oFile = fs.open("buttonOn.nfp", "w")
- oFile.writeLine("77777")
- oFile.writeLine("7eee7")
- oFile.writeLine("7eee7")
- oFile.writeLine("77777")
- oFile.flush()
- oFile.close()
- end
- if not fs.exists("buttonOff.nfp") then
- oFile = fs.open("buttonOff.nfp", "w")
- oFile.writeLine("77777")
- oFile.writeLine("78887")
- oFile.writeLine("78887")
- oFile.writeLine("77777")
- oFile.flush()
- oFile.close()
- end
- if not fs.exists("sliderX.nfp") then
- oFile = fs.open("sliderX.nfp", "w")
- oFile.writeLine("878")
- oFile.flush()
- oFile.close()
- end
- if not fs.exists("sliderY.nfp") then
- oFile = fs.open("sliderY.nfp", "w")
- oFile.writeLine("8")
- oFile.writeLine("7")
- oFile.writeLine("8")
- oFile.flush()
- oFile.close()
- end
- rednet.open("back")
- function spacewrite(string, x, y, txtcol, bakcol)
- if txtcol then
- term.setTextColor(txtcol)
- end
- if bakcol then
- term.setBackgroundColor(bakcol)
- end
- term.setCursorPos(x, y)
- term.write(string)
- end
- w, h = term.getSize()
- term.setBackgroundColor(colors.black)
- term.clear()
- local logo = paintutils.loadImage("space.nfp")
- local dial = paintutils.loadImage("dial.nfp")
- local sliderX = paintutils.loadImage("sliderX.nfp")
- local sliderY = paintutils.loadImage("sliderY.nfp")
- local buttonOn = paintutils.loadImage("buttonOn.nfp")
- local buttonOff = paintutils.loadImage("buttonOff.nfp")
- paintutils.drawImage(logo, 10, 2)
- spacewrite("SpaceTeam", 9, 5, colors.white, colors.black)
- --spacewrite("Start Game", 9, h, colors.white, colors.black)
- local start = false
- local x = nil
- local y = nil
- local tempX = nil
- local tempY = nil
- clickables = {}
- ------======DEFINES DIALS======------
- function defDial(dialX, dialY, dialName)
- term.setTextColor(colors.white)
- clickables[#clickables + 1] = {}
- clickables[#clickables][1] = dialX
- clickables[#clickables][2] = dialY
- clickables[#clickables][3] = dialName
- clickables[#clickables][4] = "Dial"
- clickables[#clickables][5] = 1
- paintutils.drawImage(dial, dialX, dialY)
- term.setCursorPos(dialX, dialY + 3)
- term.setBackgroundColor(colors.lightGray)
- term.write("/")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(dialX - 1, dialY + 4)
- term.write("1")
- term.setCursorPos(dialX - 2, dialY + 1)
- term.write("2")
- term.setCursorPos(dialX - 1, dialY - 1)
- term.write("3")
- term.setCursorPos(dialX + 2, dialY - 2)
- term.write("4")
- term.setCursorPos(dialX + 5, dialY - 1)
- term.write("5")
- term.setCursorPos(dialX + 6, dialY + 1)
- term.write("6")
- term.setCursorPos(dialX + 5, dialY + 4)
- term.write("7")
- term.setCursorPos(dialX - #dialName / 2 + 3, dialY + 5)
- term.write(dialName)
- end
- ------======DEFINES SWITCHES======------
- function defSwitch(switchX, switchY, switchDir, switchState, switchName)
- clickables[#clickables + 1] = {}
- clickables[#clickables][1] = switchX
- clickables[#clickables][2] = switchY
- clickables[#clickables][3] = switchName
- clickables[#clickables][4] = "Switch"
- clickables[#clickables][5] = switchState
- clickables[#clickables][6] = switchDir
- term.setCursorPos(switchX, switchY)
- term.setBackgroundColor(colors.gray)
- term.write(" ")
- term.setBackgroundColor(colors.lightGray)
- if switchDir == "X" then
- if switchState == true then
- term.setCursorPos(switchX + 1, switchY)
- term.write(" ")
- else
- term.setCursorPos(switchX - 3, switchY)
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(switchX + 4, switchY)
- term.write("O")
- term.setCursorPos(switchX - 4, switchY)
- term.write("X")
- term.setCursorPos(switchX - #switchName / 2 + 1, switchY + 1)
- term.write(switchName)
- elseif switchDir == "Y" then
- if switchState == true then
- for i = 3, 1, -1 do
- term.setCursorPos(switchX, switchY - i)
- term.write(" ")
- end
- else
- for i = 1, 3 do
- term.setCursorPos(switchX, switchY + i)
- term.write(" ")
- end
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(switchX, switchY - 4)
- term.write("O")
- term.setCursorPos(switchX, switchY + 4)
- term.write("X")
- term.setCursorPos(switchX - #switchName / 2 + 1, switchY + 5)
- term.write(switchName)
- end
- end
- ------======DEFINES BUTTONS======------
- function defButton(butX, butY, butState, butName)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- clickables[#clickables + 1] = {}
- clickables[#clickables][1] = butX
- clickables[#clickables][2] = butY
- clickables[#clickables][3] = butName
- clickables[#clickables][4] = "Button"
- clickables[#clickables][5] = butState
- term.setCursorPos(butX - #butName / 2 + 3, butY + 5)
- term.write(butName)
- if butState == true then
- paintutils.drawImage(buttonOn, butX, butY)
- else
- paintutils.drawImage(buttonOff, butX, butY)
- end
- end
- ------======DEFINES SLIDERS======------
- function defSlider(slideX, slideY, slideDir, slideName)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- clickables[#clickables + 1] = {}
- clickables[#clickables][1] = slideX
- clickables[#clickables][2] = slideY
- clickables[#clickables][3] = slideName
- clickables[#clickables][4] = "Slider"
- clickables[#clickables][5] = 0
- clickables[#clickables][6] = slideDir
- if slideDir == "X" then
- for i = 0, 6 do
- term.setCursorPos(slideX + i, slideY)
- term.write("-")
- end
- term.setCursorPos(slideX + 2, slideY - 1)
- term.write("0 1 2 3")
- paintutils.drawImage(sliderX, slideX - 1, slideY)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(slideX, slideY + 1)
- term.write(slideName)
- elseif slideDir == "Y" then
- for i = 0, 6 do
- term.setCursorPos(slideX, slideY + i)
- term.write("|")
- end
- for i = 0, 3 do
- term.setCursorPos(slideX - 1, slideY + 6 - i * 2)
- term.write(i)
- end
- paintutils.drawImage(sliderY, slideX, slideY + 5)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(slideX - #slideName / 2 + 1, slideY + 8)
- term.write(slideName)
- end
- end
- ------======CHECKS SWITCHES======------
- function checkSwitch(switchX, switchY)
- if e == "mouse_click" then
- tempX = x
- tempY = y
- end
- if clickables[num][6] == "X" then
- if clickables[num][5] == true then
- if m == 1 and (tempX >= switchX + 1 and tempX <= switchX + 3 and tempY == switchY) and (x >= switchX - 3 and x <= switchX - 1 and y == switchY) then
- clickables[num][5] = false
- response = false
- end
- else
- if m == 1 and (tempX >= switchX - 3 and tempX <= switchX - 1 and tempY == switchY) and (x >= switchX + 1 and x <= switchX + 3 and y == switchY) then
- clickables[num][5] = true
- response = true
- end
- end
- term.setCursorPos(switchX - 3, switchY)
- if clickables[num][5] == true then
- term.setBackgroundColor(colors.black)
- else
- term.setBackgroundColor(colors.lightGray)
- end
- term.write(" ")
- term.setCursorPos(switchX + 1, switchY)
- if clickables[num][5] == true then
- term.setBackgroundColor(colors.lightGray)
- else
- term.setBackgroundColor(colors.black)
- end
- term.write(" ")
- elseif clickables[num][6] == "Y" then
- if clickables[num][5] == true then
- if m == 1 and (tempY >= switchY - 3 and tempY <= switchY - 1 and tempX == switchX) and (y >= switchY + 1 and y <= switchY + 3 and x == switchX) then
- clickables[num][5] = false
- response = false
- end
- else
- if m == 1 and (tempY >= switchY + 1 and tempY <= switchY + 3 and tempX == switchX) and (y >= switchY - 3 and y <= switchY - 1 and x == switchX) then
- clickables[num][5] = true
- response = true
- end
- end
- if clickables[num][5] == true then
- term.setBackgroundColor(colors.lightGray)
- else
- term.setBackgroundColor(colors.black)
- end
- for i = 3, 1, -1 do
- term.setCursorPos(switchX, switchY - i)
- term.write(" ")
- end
- if clickables[num][5] == true then
- term.setBackgroundColor(colors.black)
- else
- term.setBackgroundColor(colors.lightGray)
- end
- for i = 1, 3 do
- term.setCursorPos(switchX, switchY + i)
- term.write(" ")
- end
- end
- end
- ------======CHECKS BUTTONS======------
- function checkButton(butX, butY)
- if clickables[num][5] == true then
- clickables[num][5] = false
- term.setCursorPos(butX, butY)
- paintutils.drawImage(buttonOff, butX, butY)
- response = false
- else
- clickables[num][5] = true
- term.setCursorPos(butX, butY)
- paintutils.drawImage(buttonOn, butX, butY)
- response = true
- end
- end
- ------======CHECKS SLIDERS======------
- function checkSlider(slideX, slideY)
- term.setBackgroundColor(colors.black)
- if clickables[num][6] == "X" and m == 1 and (x >= clickables[num][1] + clickables[num][5] * 2 - 1 and x <= clickables[num][1] + clickables[num][5] * 2 + 1) and (x >= clickables[num][1] and x <= clickables[num][1] + 6) and y == clickables[num][2] and e == "mouse_drag" then
- for i = 0, 6 do
- term.setCursorPos(slideX + i, slideY)
- term.write("-")
- end
- term.setCursorPos(slideX - 1, slideY)
- term.write(" ")
- term.setCursorPos(slideX + 7, slideY)
- term.write(" ")
- paintutils.drawImage(sliderX, x - 1, y)
- clickables[num][5] = (x - slideX) / 2
- response = (x - slideX) / 2
- elseif clickables[num][6] == "Y" and m == 1 and (y <= clickables[num][2] + 6 - (clickables[num][5] * 2 - 1) and y >= clickables[num][2] + 6 - (clickables[num][5] * 2 + 1)) and (y >= clickables[num][2] and y <= clickables[num][2] + 6) and x == clickables[num][1] and e == "mouse_drag" then
- for i = 0, 6 do
- term.setCursorPos(slideX, slideY + i)
- term.write("|")
- end
- term.setCursorPos(slideX, slideY - 1)
- term.write(" ")
- term.setCursorPos(slideX, slideY + 7)
- term.write(" ")
- paintutils.drawImage(sliderY, x, y - 1)
- clickables[num][5] = (slideY + 6 - y) / 2
- response = (slideY + 6 - y) / 2
- end
- end
- ------======CLEARS AND CHECKS DIALS======------
- local dialXPos = nil
- local dialYPos = nil
- function checkDial(dialX, dialY)
- dialXPos, dialYPos = nil, nil
- if clickables[num][5] == 1 then
- dialXPos, dialYPos = dialX, dialY + 3
- elseif clickables[num][5] == 2 then
- dialXPos, dialYPos = dialX - 1, clickables[num][6] --
- elseif clickables[num][5] == 3 then
- dialXPos, dialYPos = dialX, dialY
- elseif clickables[num][5] == 4 then
- dialXPos, dialYPos = clickables[num][6], dialY - 1 ---
- elseif clickables[num][5] == 5 then
- dialXPos, dialYPos = dialX + 4, dialY
- elseif clickables[num][5] == 6 then
- dialXPos, dialYPos = dialX + 5, clickables[num][6] --
- elseif clickables[num][5] == 7 then
- dialXPos, dialYPos = dialX + 4, dialY + 3
- end
- mark = nil
- if x >= dialXPos - 1 and x <= dialXPos + 1 and y >= dialYPos - 1 and y <= dialYPos + 1 then
- if x <= dialX and y >= dialY + 3 then
- xPos, yPos = dialX, dialY + 3
- mark = "/"
- clickables[num][5] = 1
- clickables[num][6] = nil
- response = 1
- elseif x < dialX and y > dialY and y < dialY + 3 then --
- xPos, yPos = dialX - 1, y
- mark = "-"
- clickables[num][5] = 2
- clickables[num][6] = y
- response = 2
- elseif x <= dialX and y <= dialY then
- xPos, yPos = dialX, dialY
- mark = "\\"
- clickables[num][5] = 3
- clickables[num][6] = nil
- response = 3
- elseif x > dialX and x < dialX + 4 and y < dialY then ---
- xPos, yPos = x, dialY - 1
- mark = "|"
- clickables[num][5] = 4
- clickables[num][6] = x
- response = 4
- elseif x >= dialX + 4 and y <= dialY then
- xPos, yPos = dialX + 4, dialY
- mark = "/"
- clickables[num][5] = 5
- clickables[num][6] = nil
- response = 5
- elseif x > dialX + 4 and y < dialY + 3 then --
- xPos, yPos = dialX + 5, y
- mark = "-"
- clickables[num][5] = 6
- clickables[num][6] = y
- response = 6
- elseif x >= dialX + 4 and y >= dialY + 3 then
- xPos, yPos = dialX + 4, dialY + 3
- mark = "\\"
- clickables[num][5] = 7
- clickables[num][6] = nil
- response = 7
- end
- if mark then
- term.setBackgroundColor(colors.black)
- term.setCursorPos(dialX, dialY + 3)
- term.write(" ")
- term.setCursorPos(dialX - 1, dialY + 2)
- term.write(" ")
- term.setCursorPos(dialX - 1, dialY + 1)
- term.write(" ")
- term.setCursorPos(dialX, dialY)
- term.write(" ")
- term.setCursorPos(dialX + 1, dialY - 1)
- term.write(" ")
- term.setCursorPos(dialX + 2, dialY - 1)
- term.write(" ")
- term.setCursorPos(dialX + 3, dialY - 1)
- term.write(" ")
- term.setCursorPos(dialX + 4, dialY)
- term.write(" ")
- term.setCursorPos(dialX + 5, dialY + 1)
- term.write(" ")
- term.setCursorPos(dialX + 5, dialY + 2)
- term.write(" ")
- term.setCursorPos(dialX + 4, dialY + 3)
- term.write(" ")
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(xPos, yPos)
- term.write(mark)
- end
- end
- end
- ------======CHECKS ALL 4 TYPES EVERY TIME THERE IS A CLICK======------
- function clickCheck()
- response = nil
- --print(x, " ", y, " ", m, " ", i)
- if m == 1 and x >= clickables[num][1] - 1 and x <= clickables[num][1] + 5 and y >= clickables[num][2] - 1 and y <= clickables[num][2] + 4 then
- if clickables[num][4] == "Dial" and e == "mouse_drag" then
- checkDial(clickables[num][1], clickables[num][2])
- elseif clickables[num][4] == "Button" and e == "mouse_click" then
- checkButton(clickables[num][1], clickables[num][2])
- end
- end
- if clickables[num][4] == "Switch" then
- checkSwitch(clickables[num][1], clickables[num][2])
- elseif clickables[num][4] == "Slider" and e == "mouse_drag" then
- checkSlider(clickables[num][1], clickables[num][2])
- end
- end
- function click()
- e, m, x, y = os.pullEvent("mouse_click")
- end
- function drag()
- e, m, x, y = os.pullEvent("mouse_drag")
- end
- ------======START MENU======------
- --defSwitch(5, 11, "X", false, "StartX")
- --defSwitch(11, 10, "Y", true, "StartY")
- --defSlider(11, 8, "X", "StartX")
- --defSlider(11, 12, "Y", "StartY")
- --defButton(11, 10, false, "Start")
- defDial(11, 10, "Start")
- while not start do
- e, m, x, y = nil, nil, nil, nil
- parallel.waitForAny(click, drag)
- num = 1
- for i = 1, #clickables do
- clickCheck()
- num = num + 1
- if response == 7 then
- start = true
- end
- end
- end
- sleep(.3)
- term.setBackgroundColor(colors.black)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.gray)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.white)
- term.clear()
- sleep(.3)
- ------======COMPUTERS CONNECT======------
- term.setBackgroundColor(colors.black)
- term.clear()
- spacewrite("Searching for signals...", 2, 1, colors.white, colors.black)
- clickables = {}
- response = nil
- local id = nil
- local host = nil
- local cast = "ping"
- local connected = false
- while not connected do
- rednet.broadcast(cast)
- spacewrite("Searching for signals...", 2, 1, colors.white, colors.black)
- local randX = math.random(1, w)
- local randY = math.random(2, h)
- local randMark = math.random(1, 2)
- if randMark == 1 then
- spacewrite("*", randX, randY, colors.white, colors.black)
- else
- spacewrite(" ", randX, randY, colors.white, colors.black)
- end
- --print(cast .. "...")
- otherID, response = rednet.receive(.01)
- if response == "ping" or response == "ready" then
- id = otherID
- host = true
- --print("Ping Recieved")
- end
- if id then cast = "ready" end
- if response == "ready" and id then
- rednet.send(id, "ready")
- connected = true
- term.clear()
- term.setCursorPos(1, 1)
- --print("Connected to id: " ..id)
- end
- end
- term.setBackgroundColor(colors.black)
- term.clear()
- for i = w, -8, -1 do
- term.setBackgroundColor(colors.white)
- term.clear()
- spacewrite("Team Up!", i, 10, colors.lightBlue, colors.white)
- sleep(.01)
- term.setBackgroundColor(colors.black)
- term.clear()
- spacewrite("Team Up!", i, 10, colors.orange, colors.black)
- sleep(.01)
- end
- function receive()
- e, id, message = os.pullEvent("rednet_message")
- end
- function key()
- e, string = os.pullEvent("char")
- --rednet.send(id, string)
- end
- ------======TICK======------
- local toggle = false
- local tickcount = 0
- function tick()
- countnum = countnum - .4
- spacewrite(" ", done + 2, 1, colors.white, colors.lightGray)
- tickcount = tickcount + 1
- if tickcount >= 1 then
- if toggle then
- toggle = false
- term.setBackgroundColor(colors.blue)
- else
- toggle = true
- term.setBackgroundColor(colors.lightBlue)
- end
- tickcount = 0
- end
- term.setCursorPos(done + 1, 1)
- term.write(" ")
- rednet.send(id, taskwrite)
- --sleep(.1)
- os.startTimer(.4)
- end
- ------======PANEL GENERATOR======------
- names = {"Quark", "Zions", "Alias", "Zen", "Quigo", "Zefyr", "Plag", "Swurt", "Fork", "Arp", "Dilk", "Frazz", "Cacim", "Mcalk", "Rish", "Vilin", "Pagel", "Entio", "Ishop", "Takil", "Rouk", "Pon", "Lapor", "Xylph", "V-net", "X-gab", "F-win", "L-map", "D-op", "W-yam", "Geysu", "Gick", "Pflap", "Aport"}
- function generateConsole()
- local genX = 2
- local genY = 7
- local genW = 0
- local genH = 0
- local genDir = 0
- local genDirMax = 0
- local genName = nil
- local genState = nil
- local topGenW = 0
- term.setBackgroundColor(colors.black)
- term.clear()
- clickables = {}
- genNameUsed = {}
- while true do
- genName = math.random(1, #names)
- if not genNameUsed[genName] then
- genNameUsed[genName] = true
- genName = names[genName]
- genMax = 0
- if w - genX >= 11 then
- genMax = 4
- elseif w - genX >= 7 then
- genMax = 3
- elseif w - genX < 7 then
- --generation completed
- break
- end
- if w - genX < 9 then
- genDirMax = 1
- else
- genDirMax = 2
- end
- type = math.random(1, genMax)
- if type == 1 then
- type = "Button"
- genW = 7
- genH = 8
- genState = math.random(0, 1)
- if genState == 1 then
- genState = true
- elseif genState == 0 then
- genState = false
- end
- elseif type == 2 then
- type = "Slider"
- genDir = math.random(1, genDirMax)
- if genDir == 1 then
- genDir = "Y"
- genW = 7
- genH = 11
- elseif genDir == 2 then
- genDir = "X"
- genW = 9
- genH = 5
- end
- elseif type == 3 then
- type = "Switch"
- genDir = math.random(1, 2)
- if genDir == 1 then
- genDir = "Y"
- genW = 7
- genH = 13
- elseif genDir == 2 then
- genDir = "X"
- genW = 11
- genH = 5
- end
- genState = math.random(0, 1)
- if genState == 1 then
- genState = true
- elseif genState == 0 then
- genState = false
- end
- elseif type == 4 then
- type = "Dial"
- genW = 11
- genH = 10
- end
- if genY == 7 then
- topGenW = genW
- end
- if genY + genH > h then
- genX = genX + topGenW
- genY = 7
- else
- if type == "Button" then
- defButton(genX + 1, genY + 1, genState, genName)
- elseif type == "Slider" then
- if genDir == "X" then
- defSlider(genX + 1, genY + 2, genDir, genName)
- elseif genDir == "Y" then
- defSlider(genX + 3, genY + 1, genDir, genName)
- end
- elseif type == "Switch" then
- if genDir == "X" then
- defSwitch(genX + 5, genY + 2, genDir, genState, genName)
- elseif genDir == "Y" then
- defSwitch(genX + 3, genY + 5, genDir, genState, genName)
- end
- elseif type == "Dial" then
- defDial(genX + 3, genY + 3, genName)
- end
- --term.setCursorPos(genX, genY)
- --term.write("x")
- --genX = genX + genW
- genY = genY + genH
- --term.setCursorPos(genX, genY)
- --term.write("y")
- end
- end
- end
- end
- ------======ACTUAL GAME======------
- keys = {"q","w","e","r","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"}
- done = 0
- sector = 1
- countnum = nil
- newtask = nil
- taskwrite = nil
- local alive = true
- local event = {}
- initialized = false
- countnum = 13 - sector
- generateConsole()
- os.startTimer(.4)
- while alive do
- taskwrite = nil
- task = math.random(1, #clickables + 1)
- if task == #clickables + 1 then
- task = keys[math.random(1, 26)]
- taskwrite = "Press " .. task
- clickablenum = nil
- else
- clickablenum = task
- if clickables[task][4] == "Button" then
- if clickables[task][5] == false then
- taskwrite = "Engage " .. clickables[task][3]
- task = true
- else
- taskwrite = "Disengage " .. clickables[task][3]
- task = false
- end
- elseif clickables[task][4] == "Slider" then
- taskRand = math.random(0, 3)
- while clickables[task][5] == taskRand do
- taskRand = math.random(0, 3)
- end
- taskwrite = "Set " .. clickables[task][3] .. " to " .. tostring(taskRand)
- task = taskRand
- elseif clickables[task][4] == "Switch" then
- if clickables[task][5] == false then
- taskwrite = "Activate " .. clickables[task][3]
- task = true
- else
- taskwrite = "Deactivate " .. clickables[task][3]
- task = false
- end
- elseif clickables[task][4] == "Dial" then
- taskRand = math.random(1, 7)
- while clickables[task][5] == taskRand do
- taskRand = math.random(1, 7)
- end
- taskwrite = "Set " .. clickables[task][3] .. " to " .. tostring(taskRand)
- task = taskRand
- end
- end
- rednet.send(id, taskwrite)
- cast = taskwrite
- while not initialized do
- response = nil
- rednet.send(id, cast)
- otherID, response = rednet.receive(.01)
- if response and response ~= "complete" and response ~= "init" and response ~= "dead" and response ~= "nextsector" and response ~= "go" then
- newtask = response
- cast = "init"
- end
- if response == "init" and newtask then
- rednet.send(id, "init")
- initialized = true
- end
- end
- --spacewrite(tostring(done) .. " tasks completed...", 1, 3, colors.white, colors.black)
- complete = false
- while not complete do
- spacewrite("Sector: " .. tostring(sector), 9, 2, colors.white, colors.black)
- spacewrite(" ", 1, 4, colors.white, colors.black)
- newtask = assert(newtask, "ERROR: newtask is nil")
- spacewrite(newtask, 1, 4, colors.white, colors.black)
- spacewrite(" ", 1, 5)
- if (countnum / (13 - sector)) > .75 then
- term.setBackgroundColor(colors.lime)
- elseif (countnum / (13 - sector)) > .5 then
- term.setBackgroundColor(colors.yellow)
- elseif (countnum / (13 - sector)) > .25 then
- term.setBackgroundColor(colors.orange)
- else
- term.setBackgroundColor(colors.red)
- end
- term.setCursorPos(1, 5)
- for i = 1, (countnum / (13 - sector)) * w do
- term.write(" ")
- end
- --term.setCursorPos(1, h)
- --term.write(countnum)
- e, m, x, y, string, message = nil, nil, nil, nil, nil, nil
- --parallel.waitForAny(receive, key, tick, click, drag)
- event = {os.pullEventRaw()}
- if event[1] == "timer" then
- tick()
- elseif event[1] == "mouse_click" then
- e, m, x, y = event[1], event[2], event[3], event[4]
- elseif event[1] == "mouse_drag" then
- e, m, x, y = event[1], event[2], event[3], event[4]
- elseif event[1] == "rednet_message" then
- otherID, message = event[2], event[3]
- elseif event[1] == "key" then
- string = event[2]
- end
- num = 1
- if message and message ~= "complete" and message ~= "init" and message ~= "dead" and message ~= "nextsector" and message ~= "go" then
- newtask = message
- end
- if x and y then
- for i = 1, #clickables do
- clickCheck()
- num = num + 1
- if clickablenum and clickables[clickablenum][5] == task then
- rednet.send(id, "complete")
- complete = true
- done = done + 1
- term.setCursorPos(done, 1)
- term.setBackgroundColor(colors.black)
- term.write(" ")
- end
- end
- end
- --if complete then break end
- if not clickablenum and string == task then
- rednet.send(id, "complete")
- complete = true
- done = done + 1
- term.setCursorPos(done, 1)
- term.setBackgroundColor(colors.black)
- term.write(" ")
- end
- if message == "complete" then
- countnum = 13 - sector
- --otherID, newtask = rednet.receive(.1)
- done = done + 1
- term.setCursorPos(done, 1)
- term.setBackgroundColor(colors.black)
- term.write(" ")
- spacewrite(" ", 1, 4, colors.white, colors.lime)
- sleep(.01)
- spacewrite(" ", 1, 4, colors.white, colors.black)
- end
- if done >= 24 or message == "nextsector" then
- movingon = false
- ready = false
- cast = "nextsector"
- while not movingon do
- response = nil
- rednet.send(id, cast)
- otherID, response = rednet.receive(.01)
- if response == "nextsector" or response == "go" then
- cast = "go"
- ready = true
- end
- if response == "go" and ready then
- rednet.send(id, "nextsector")
- rednet.send(id, "go")
- movingon = true
- end
- end
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- textutils.slowPrint(" HYPERSPACE!!! ")
- sleep(.3)
- term.setBackgroundColor(colors.white)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.gray)
- term.clear()
- sleep(.3)
- term.setBackgroundColor(colors.black)
- term.clear()
- sleep(.3)
- term.setTextColor(colors.white)
- sector = sector + 1
- initialized = false
- done = 0
- newtask = nil
- taskwrite = nil
- countnum = 13 - sector
- spacewrite(" ", 25, 1, colors.white, colors.black)
- generateConsole()
- os.startTimer(.4)
- complete = true
- end
- if countnum <= 0 or message == "dead" then
- term.setCursorPos(1, h)
- term.setBackgroundColor(colors.red)
- rednet.send(id, "dead")
- textutils.slowPrint("Critical Failiure...")
- alive = false
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement