Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------======LOCALIZED VARIABLES======------
- local w, h = term.getSize()
- local midW, midH = math.floor(w/2), math.floor(h/2)
- local events = {}
- local logo = {{0, 1, 1, 1, 1, 1, 1}, {0, 1, 1, 0, 1, 1, 0}, {1, 1, 1, 0, 1, 1, 0}}
- if not fs.exists("clickables") then
- shell.run("pastebin get Je7BEsW3 clickables")
- end
- os.loadAPI("clickables")
- ------======GAME FUNCTIONS======------
- function rednetTest()
- rednet.open("back")
- end
- if not pcall(rednetTest) then
- --error("ERROR: device must have wireless capability")
- end
- if not fs.exists("clickables") then
- shell.run("pastebin get Je7BEsW3 clickables")
- end
- for i,v in pairs(colors) do
- if tonumber(v) then
- loadstring(i .. "=" .. v)()
- end
- end
- function draw(string, x, y, txtcol, bakcol)
- string = string or ""
- txtcol = txtcol or colors.white
- bakcol = bakcol or colors.black
- if not tonumber(x) then
- x = x:gsub(" ", "")
- if x:sub(1, 1) == "l" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(1 + offset, y)
- else
- term.setCursorPos(1, y)
- end
- elseif x:sub(1, 1) == "c" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(w/2 - #string/2 + 1 + offset, y)
- elseif x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w/2 - #string/2 + 1 - offset, y)
- else
- term.setCursorPos(w/2 - #string/2 + 1, y)
- end
- elseif x:sub(1, 1) == "r" then
- if x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w - #string + 1 - offset, y)
- else
- term.setCursorPos(w - #string + 1, y)
- end
- end
- else
- term.setCursorPos(x, y)
- end
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(string)
- end
- function waitForSignal(receiverID, timeOut)
- local signalTimer
- if timeOut then
- signalTimer = os.startTimer(timeOut)
- end
- while true do
- if receiverID then
- rednet.send(receiverID, "ping")
- else
- rednet.broadcast("ping")
- end
- local events = {os.pullEvent()}
- if events[1] == "rednet_message" and events[2] == "ping" then
- rednet.send(events[2], "ping")
- return events[2]
- elseif signalTimer and events[1] == "timer" and events[2] == signalTimer then
- break
- end
- coroutine.yield()
- end
- return false
- end
- function starScreen()
- while true do
- randCheck = math.random(1, 3)
- if randCheck == 1 then
- randY = math.random(2, h)
- while stars[randY] do
- randY = math.random(2, h)
- end
- stars[randY] = w
- end
- for i, v in pairs(stars) do
- if v < 1 then
- deleteprev = true
- term.setCursorPos(1, i)
- term.write(" ")
- else
- if deleteprev then
- if i == 2 then
- stars[h] = nil
- else
- stars[i - 1] = nil
- end
- end
- term.setCursorPos(v, i)
- term.write("*")
- term.setCursorPos(v + 1, i)
- term.write(" ")
- stars[i] = v - 1
- deleteprev = false
- end
- end
- coroutine.yield()
- end
- end
- function gameConnect()
- local signal = coroutine.create(waitForSignal())
- local stars = coroutine.create(starScreen())
- while coroutine.status(signal) ~= "dead" do
- coroutine.resume(signal)
- print("stars next")
- coroutine.resume(stars)
- print("signal next")
- end
- end
- ------======MAIN MENU======------
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- paintutils.drawImage(logo, midW - 3, 2)
- draw("Spaceteam", "c", 5, colors.white, colors.black)
- local Start = clickables.Dial:new("Start", midW - 2, 10)
- while true do
- Start:display()
- events = {}
- clickables.getEvents()
- --if Start:check() == 7 then
- break
- --end
- end
- sleep(.2)
- term.setBackgroundColor(colors.black)
- term.clear()
- sleep(.2)
- term.setBackgroundColor(colors.gray)
- term.clear()
- sleep(.2)
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- sleep(.2)
- term.setBackgroundColor(colors.white)
- term.clear()
- sleep(.2)
- term.setBackgroundColor(colors.black)
- term.clear()
- ------======SIGNAL SEARCH======------
- local stars = {}
- local deleteprev = false
- draw("Searching for signals...", 1, 1)
- --[[while true do
- id, message = nil, nil
- randCheck = math.random(1, 3)
- if randCheck == 1 then
- randY = math.random(2, h)
- while stars[randY] do
- randY = math.random(2, h)
- end
- stars[randY] = w
- end
- for i, v in pairs(stars) do
- if v < 1 then
- deleteprev = true
- term.setCursorPos(1, i)
- term.write(" ")
- else
- if deleteprev then
- if i == 2 then
- stars[h] = nil
- else
- stars[i - 1] = nil
- end
- end
- term.setCursorPos(v, i)
- term.write("*")
- term.setCursorPos(v + 1, i)
- term.write(" ")
- stars[i] = v - 1
- deleteprev = false
- end
- end
- rednet.broadcast("ping")
- id, message = rednet.receive(.1)
- if id and message == "ping" then
- rednet.send(id, "ping")
- break
- end
- end--]]
- gameConnect()
- sleep(.2)
- term.setBackgroundColor(colors.white)
- term.clear()
- for i = w, -7, -1 do
- draw("Team Up! ", i, h/2, orange, white)
- sleep(.05)
- draw("Team Up! ", i, h/2, blue, white)
- sleep(.05)
- end
- ------======START GAME======------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement