-— Stargate Universe controller for SGJourney
-- === Peripherals ===
local gate = peripheral.find("advanced_crystal_interface")
if not gate then error("No advanced_crystal_interface found!") end
local display = peripheral.find("monitor")
if not display then error("No monitor found!") end
-- === Address List ===
local addressList = {
{1,2,3,4,5,6,7,8,0},
{8,1,22,14,36,19,0},
{10,11,12,13,14,15,16,17,0}
-- Add more if needed
}
-- === Timers (in seconds) ===
local minReentryWait = 3200 -- 1 hour
local maxReentryWait = 7200 -- 2 hours
local minGateTime = 1800 -- 30 minutes
local maxGateTime = 7200 -- 2 hours
-- === Network Setup ===
local destinyNetworkID = 450321
-- === Logging ===
local function timestamp()
return "[" .. textutils.formatTime(os.time(), true) .. "]"
end
local function log(msg)
print(timestamp() .. " " .. msg)
end
-- === Monitor Output ===
display.setTextScale(0.5)
display.setBackgroundColor(colors.black)
local function updateMonitor(status)
display.clear()
display.setCursorPos(2, 2)
display.setTextColor(colors.yellow)
display.write("DESTINY STATUS")
display.setCursorPos(2, 4)
display.setTextColor(colors.lime)
display.write(status)
end
-- === Strip origin symbol (0) ===
local function stripOrigin(address)
local clean = {}
for _, symbol in ipairs(address) do
if symbol ~= 0 then table.insert(clean, symbol) end
end
return clean
end
-- === Dial Address ===
local function dialAddress(address)
for _, symbol in ipairs(address) do
gate.engageSymbol(symbol)
sleep(1)
end
end
-- === Countdown with no visible timer (SGU style) ===
local function countdown(duration)
updateMonitor("IN FTL")
for i = duration, 0, -1 do
sleep(1) -- Quiet FTL travel, no time shown
end
end
-- === Random Address Picker ===
local lastIndex = nil
local function pickNewTarget()
local index
repeat
index = math.random(1, #addressList)
until index ~= lastIndex
lastIndex = index
return addressList[index]
end
-- === Main Loop ===
log("Destiny controller started.")
updateMonitor("IN FTL")
while true do
-- PHASE 1: FTL Countdown (no visible time)
local ftlWait = math.random(minReentryWait, maxReentryWait)
log("Destiny in FTL. Countdown to re-entry started.")
countdown(ftlWait)
-- PHASE 2: Re-entry — pick and dial destination
local target = pickNewTarget()
log("Re-entry complete. Dialing: {" .. table.concat(target, ",") .. "}")
gate.clearWhitelist()
gate.addToWhitelist(stripOrigin(target))
gate.setFilterType(1) -- Whitelist mode
gate.setNetwork(destinyNetworkID)
gate.restrictNetwork(true)
dialAddress(target)
log("Whitelist and network restriction set.")
updateMonitor("GATE ONLINE")
-- PHASE 3: Gate window remains open
local openTime = math.random(minGateTime, maxGateTime)
log("Gate will remain open for " .. math.floor(openTime / 60) .. " minutes.")
sleep(openTime)
-- PHASE 4: FTL resumes
gate.clearWhitelist()
gate.setFilterType(1) -- Keep gate locked
updateMonitor("IN FTL")
log("Gate locked. Destiny has re-entered FTL.")
end