Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Find den avancerede krystal-interface og monitor
- interface = peripheral.find("advanced_crystal_interface")
- monitor = peripheral.wrap("top") -- Sørg for, at den er korrekt monteret på computeren
- -- Indstil tekstskala for monitoren (kan justeres)
- monitor.setTextScale(0.5)
- -- Redstone output (bag computeren)
- redstoneSide = "back" -- Den side, som redstone-signalet skal sendes ud fra
- -- Dial-funktion med grafikopdatering
- function dial(address)
- redstone.setOutput(redstoneSide, true)
- local addressLength = #address
- if addressLength == 8 then
- interface.setChevronConfiguration({0, 1, 2, 3, 4, 6, 7, 8, 5})
- elseif addressLength == 9 then
- interface.setChevronConfiguration({0, 1, 2, 3, 4, 5, 6, 7, 8})
- end
- local start = interface.getChevronsEngaged() + 1
- for chevron = start, addressLength do
- local symbol = address[chevron]
- if chevron % 2 == 0 then
- interface.rotateClockwise(symbol)
- else
- interface.rotateAntiClockwise(symbol)
- end
- while not interface.isCurrentSymbol(symbol) do
- sleep(0)
- end
- interface.endRotation()
- sleep(1)
- interface.openChevron()
- -- Opdater grafik med aktiveret chevron
- drawGate(chevron)
- sleep(0.5)
- if chevron < addressLength then
- interface.encodeChevron()
- end
- sleep(0.5)
- interface.closeChevron()
- sleep(1)
- end
- redstone.setOutput(redstoneSide, false)
- end
- -- Funktion til at lukke Stargaten
- function closeGate()
- interface.disconnectStargate()
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Stargate lukket.")
- redstone.setOutput(redstoneSide, false)
- sleep(2)
- drawUI()
- end
- -- Stargate-adresser
- addresses = {
- {name = "Abydos", address = {26, 6, 14, 31, 11, 29, 0}},
- {name = "Chulak", address = {8, 1, 22, 14, 36, 19, 0}},
- {name = "Lantea", address = {18, 20, 1, 15, 14, 7, 19, 0}},
- {name = "Nether", address = {27, 23, 4, 34, 12, 28, 0}},
- {name = "Cavum Tenebrae", address = {18, 7, 3, 36, 25, 15, 0}},
- {name = "End", address = {13, 24, 2, 19, 3, 30, 0}}
- }
- -- Tegn UI med farver og grafik
- function drawUI()
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.cyan)
- monitor.write("=== Milky Way Stargate Control ===")
- monitor.setTextColor(colors.white)
- for i, destination in ipairs(addresses) do
- local yPos = 2 + (i * 2)
- monitor.setCursorPos(2, yPos)
- monitor.setBackgroundColor(colors.gray)
- monitor.clearLine()
- monitor.write(" " .. i .. ". " .. destination.name .. " ")
- end
- local closeY = 2 + (#addresses + 1) * 2
- monitor.setCursorPos(2, closeY)
- monitor.setBackgroundColor(colors.orange)
- monitor.clearLine()
- monitor.write(" 7. Luk Stargate ")
- drawGate(0) -- Tegn grafikken uden aktiverede chevrons
- end
- -- Funktion til at registrere touch-input
- function handleTouch(event, side, x, y)
- local index = math.floor((y - 2) / 2)
- if index >= 1 and index <= #addresses then
- dial(addresses[index].address)
- elseif y == 2 + (#addresses + 1) * 2 then
- closeGate()
- end
- end
- -- Hovedprogram-loop
- drawUI()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- if side == "top" then
- handleTouch(event, side, x, y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment