Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = {}
- function defDial(dialX, dialY, dialName)
- 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
- 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.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.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
- function defButton(butX, butY, butState, butName)
- 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
- function defSlider(slideX, slideY, slideDir, slideName)
- 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
- term.setBackgroundColor(colors.black)
- if slideDir == "X" then
- for i = 0, 6 do
- term.setCursorPos(slideX + i, slideY)
- term.write("-")
- end
- for i = 0, 3 do
- term.setCursorPos(slideX + i * 2, slideY - 1)
- term.write(i)
- end
- paintutils.drawImage(sliderX, slideX - 1, slideY)
- 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.setCursorPos(slideX - #slideName / 2 + 3, slideY + 8)
- term.write(slideName)
- end
- end
- 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
- 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
- function checkSlider(slideX, slideY)
- term.setBackgroundColor(colors.black)
- if clickables[num][6] == "X" and m == 1 and (x >= clickables[num][1] + clickables[num][5] - 1 and x <= clickables[num][1] + clickables[num][5] + 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
- response = (x - slideX) / 2
- elseif clickables[num][6] == "Y" and m == 1 and (y >= clickables[num][2] + clickables[num][5] - 1 and y <= clickables[num][2] + clickables[num][5] + 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] = y - slideY
- response = (slideY + 6 - y) / 2
- end
- end
- function checkDial(dialX, dialY)
- 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(" ")
- if x <= dialX and y >= dialY + 3 then
- xPos, yPos = dialX, dialY + 3
- mark = "/"
- clickables[num][5] = 1
- response = 1
- elseif x < dialX and y > dialY and y < dialY + 3 then
- xPos, yPos = dialX - 1, y
- mark = "-"
- clickables[num][5] = 2
- response = 2
- elseif x <= dialX and y <= dialY then
- xPos, yPos = dialX, dialY
- mark = "\\"
- clickables[num][5] = 3
- response = 3
- elseif x > dialX and x < dialX + 4 and y < dialY then
- xPos, yPos = x, dialY - 1
- mark = "|"
- clickables[num][5] = 4
- response = 4
- elseif x >= dialX + 4 and y <= dialY then
- xPos, yPos = dialX + 4, dialY
- mark = "/"
- clickables[num][5] = 5
- response = 5
- elseif x > dialX + 4 and y < dialY + 3 then
- xPos, yPos = dialX + 5, y
- mark = "-"
- clickables[num][5] = 6
- response = 6
- elseif x >= dialX + 4 and y >= dialY + 3 then
- xPos, yPos = dialX + 4, dialY + 3
- mark = "\\"
- clickables[num][5] = 7
- response = 7
- end
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(xPos, yPos)
- term.write(mark)
- end
- 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
- --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)
- 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.broadcast("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
- local toggle = false
- function w8()
- sleep(.1)
- num = num - .1
- spacewrite(" ", done + 2, 1, colors.white, colors.lightGray)
- if toggle then
- toggle = false
- term.setBackgroundColor(colors.blue)
- else
- toggle = true
- term.setBackgroundColor(colors.lightBlue)
- end
- term.setCursorPos(done + 1, 1)
- term.write(" ")
- end
- 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
- local alive = true
- while alive do
- num = 13 - sector
- task = keys[math.random(1, 26)]
- spacewrite("Press " .. task, 1, h - 1, colors.white, colors.black)
- --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)
- term.setBackgroundColor(colors.black)
- spacewrite(" ", 1, h, colors.white, colors.black)
- if (num / 12) > .75 then
- term.setBackgroundColor(colors.lime)
- elseif (num / 12) > .5 then
- term.setBackgroundColor(colors.yellow)
- elseif (num / 12) > .25 then
- term.setBackgroundColor(colors.orange)
- else
- term.setBackgroundColor(colors.red)
- end
- term.setCursorPos(1, h)
- for i = 1, (num / 12) * w do
- term.write(" ")
- end
- --term.setCursorPos(1, h)
- --term.write(num)
- string, message = nil, nil
- parallel.waitForAny(receive, key, w8)
- if message == 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
- done = done + 1
- term.setCursorPos(done, 1)
- term.setBackgroundColor(colors.black)
- term.write(" ")
- end
- if done == 24 then
- sector = sector + 1
- done = 0
- spacewrite(" ", 25, 1, colors.white, colors.black)
- end
- if num <= 0 then
- term.setCursorPos(1, h)
- term.setBackgroundColor(colors.red)
- textutils.slowPrint("Critical Failiure...")
- alive = false
- break
- end
- end
- end
Add Comment
Please, Sign In to add comment