Puffymania

stargate journey 5

Sep 21st, 2024 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. -- Find den avancerede krystal-interface og monitor
  2. interface = peripheral.find("advanced_crystal_interface")
  3. monitor = peripheral.wrap("top") -- Sørg for, at den er korrekt monteret på computeren
  4.  
  5. -- Indstil tekstskala for monitoren (kan justeres)
  6. monitor.setTextScale(0.5)
  7.  
  8. -- Redstone output (bag computeren)
  9. redstoneSide = "back" -- Den side, som redstone-signalet skal sendes ud fra
  10.  
  11. -- Dial-funktion med grafikopdatering
  12. function dial(address)
  13. redstone.setOutput(redstoneSide, true)
  14.  
  15. local addressLength = #address
  16.  
  17. if addressLength == 8 then
  18. interface.setChevronConfiguration({0, 1, 2, 3, 4, 6, 7, 8, 5})
  19. elseif addressLength == 9 then
  20. interface.setChevronConfiguration({0, 1, 2, 3, 4, 5, 6, 7, 8})
  21. end
  22.  
  23. local start = interface.getChevronsEngaged() + 1
  24.  
  25. for chevron = start, addressLength do
  26. local symbol = address[chevron]
  27.  
  28. if chevron % 2 == 0 then
  29. interface.rotateClockwise(symbol)
  30. else
  31. interface.rotateAntiClockwise(symbol)
  32. end
  33.  
  34. while not interface.isCurrentSymbol(symbol) do
  35. sleep(0)
  36. end
  37. interface.endRotation()
  38.  
  39. sleep(1)
  40. interface.openChevron()
  41.  
  42. -- Opdater grafik med aktiveret chevron
  43. drawGate(chevron)
  44.  
  45. sleep(0.5)
  46. if chevron < addressLength then
  47. interface.encodeChevron()
  48. end
  49. sleep(0.5)
  50. interface.closeChevron()
  51. sleep(1)
  52. end
  53.  
  54. redstone.setOutput(redstoneSide, false)
  55. end
  56.  
  57. -- Funktion til at lukke Stargaten
  58. function closeGate()
  59. interface.disconnectStargate()
  60. monitor.clear()
  61. monitor.setCursorPos(1, 1)
  62. monitor.write("Stargate lukket.")
  63.  
  64. redstone.setOutput(redstoneSide, false)
  65.  
  66. sleep(2)
  67. drawUI()
  68. end
  69.  
  70. -- Stargate-adresser
  71. addresses = {
  72. {name = "Abydos", address = {26, 6, 14, 31, 11, 29, 0}},
  73. {name = "Chulak", address = {8, 1, 22, 14, 36, 19, 0}},
  74. {name = "Lantea", address = {18, 20, 1, 15, 14, 7, 19, 0}},
  75. {name = "Nether", address = {27, 23, 4, 34, 12, 28, 0}},
  76. {name = "Cavum Tenebrae", address = {18, 7, 3, 36, 25, 15, 0}},
  77. {name = "End", address = {13, 24, 2, 19, 3, 30, 0}}
  78. }
  79.  
  80. -- Tegn UI med farver og grafik
  81. function drawUI()
  82. monitor.clear()
  83.  
  84. monitor.setCursorPos(1, 1)
  85. monitor.setTextColor(colors.cyan)
  86. monitor.write("=== Milky Way Stargate Control ===")
  87. monitor.setTextColor(colors.white)
  88.  
  89. for i, destination in ipairs(addresses) do
  90. local yPos = 2 + (i * 2)
  91. monitor.setCursorPos(2, yPos)
  92. monitor.setBackgroundColor(colors.gray)
  93. monitor.clearLine()
  94. monitor.write(" " .. i .. ". " .. destination.name .. " ")
  95. end
  96.  
  97. local closeY = 2 + (#addresses + 1) * 2
  98. monitor.setCursorPos(2, closeY)
  99. monitor.setBackgroundColor(colors.orange)
  100. monitor.clearLine()
  101. monitor.write(" 7. Luk Stargate ")
  102.  
  103. drawGate(0) -- Tegn grafikken uden aktiverede chevrons
  104. end
  105.  
  106. -- Funktion til at registrere touch-input
  107. function handleTouch(event, side, x, y)
  108. local index = math.floor((y - 2) / 2)
  109. if index >= 1 and index <= #addresses then
  110. dial(addresses[index].address)
  111. elseif y == 2 + (#addresses + 1) * 2 then
  112. closeGate()
  113. end
  114. end
  115.  
  116. -- Hovedprogram-loop
  117. drawUI()
  118.  
  119. while true do
  120. local event, side, x, y = os.pullEvent("monitor_touch")
  121. if side == "top" then
  122. handleTouch(event, side, x, y)
  123. end
  124. end
  125.  
Advertisement
Add Comment
Please, Sign In to add comment