MomoFloFlo

cl2

Nov 8th, 2025
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.49 KB | None | 0 0
  1. -- nanomachine_client.lua
  2. -- Designed by fxllenfx for fx-Studios
  3. -- Advanced Nanomachine Control System v2.0
  4.  
  5. local component = require("component")
  6. local event = require("event")
  7. local term = require("term")
  8. local gpu = component.gpu
  9. local serialization = require("serialization")
  10.  
  11. -- Config
  12. local SERVER_ADDR = nil
  13. local PORT = 2000
  14. local modem = component.modem
  15. local nano = component.nanomachines
  16.  
  17. -- UI State
  18. local currentScreen = "main"
  19. local selectedProfile = nil
  20. local scrollOffset = 0
  21. local statusData = {}
  22. local profiles = {}
  23. local discoveryActive = false
  24. local discoveryProgress = 0
  25.  
  26. -- Colors
  27. local COLOR_BG = 0x000000
  28. local COLOR_FG = 0xFFFFFF
  29. local COLOR_HEADER = 0x00FFFF
  30. local COLOR_SUCCESS = 0x00FF00
  31. local COLOR_WARNING = 0xFFFF00
  32. local COLOR_ERROR = 0xFF0000
  33. local COLOR_ACTIVE = 0x00FF00
  34. local COLOR_INACTIVE = 0x888888
  35. local COLOR_BUTTON = 0x0066CC
  36. local COLOR_SELECTED = 0xFF6600
  37. local COLOR_FX = 0xFF00FF
  38.  
  39. -- Boot Animation
  40. local function bootAnimation()
  41.   term.clear()
  42.   gpu.setBackground(COLOR_BG)
  43.   gpu.setResolution(80, 25)
  44.  
  45.   local startY = 8
  46.  
  47.   -- fx-Studios stylized text (using box drawing characters)
  48.   gpu.setForeground(COLOR_FX)
  49.   local logo1 = "███████╗██╗  ██╗      ███████╗████████╗██╗   ██╗██████╗ ██╗ ██████╗ ███████╗"
  50.   local logo2 = "██╔════╝╚██╗██╔╝      ██╔════╝╚══██╔══╝██║   ██║██╔══██╗██║██╔═══██╗██╔════╝"
  51.   local logo3 = "█████╗   ╚███╔╝ █████╗███████╗   ██║   ██║   ██║██║  ██║██║██║   ██║███████╗"
  52.   local logo4 = "██╔══╝   ██╔██╗ ╚════╝╚════██║   ██║   ██║   ██║██║  ██║██║██║   ██║╚════██║"
  53.   local logo5 = "██║     ██╔╝ ██╗      ███████║   ██║   ╚██████╔╝██████╔╝██║╚██████╔╝███████║"
  54.   local logo6 = "╚═╝     ╚═╝  ╚═╝      ╚══════╝   ╚═╝    ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝"
  55.  
  56.   -- Animated reveal
  57.   gpu.set(1, startY, logo1)
  58.   os.sleep(0.12)
  59.   gpu.set(1, startY + 1, logo2)
  60.   os.sleep(0.12)
  61.   gpu.set(1, startY + 2, logo3)
  62.   os.sleep(0.12)
  63.   gpu.set(1, startY + 3, logo4)
  64.   os.sleep(0.12)
  65.   gpu.set(1, startY + 4, logo5)
  66.   os.sleep(0.12)
  67.   gpu.set(1, startY + 5, logo6)
  68.  
  69.   os.sleep(0.5)
  70.  
  71.   -- Subtitle
  72.   gpu.setForeground(COLOR_HEADER)
  73.   local subtitle = "NANOMACHINE CONTROL SYSTEM v2.0"
  74.   gpu.set(math.floor((80 - #subtitle) / 2), startY + 7, subtitle)
  75.  
  76.   os.sleep(0.3)
  77.  
  78.   -- Credits
  79.   gpu.setForeground(COLOR_FX)
  80.   local credit = "» Designed by fxllenfx «"
  81.   gpu.set(math.floor((80 - #credit) / 2), startY + 9, credit)
  82.  
  83.   os.sleep(0.6)
  84.  
  85.   -- Loading bar
  86.   gpu.setForeground(COLOR_SUCCESS)
  87.   local loadText = "[ Initialisiere System ]"
  88.   gpu.set(math.floor((80 - #loadText) / 2), startY + 11, loadText)
  89.  
  90.   local barWidth = 50
  91.   local barX = math.floor((80 - barWidth - 2) / 2)
  92.   local barY = startY + 12
  93.  
  94.   gpu.setForeground(COLOR_INACTIVE)
  95.   gpu.set(barX, barY, "[" .. string.rep("░", barWidth) .. "]")
  96.  
  97.   for i = 1, barWidth do
  98.     local color = COLOR_FX
  99.     if i < barWidth * 0.33 then
  100.       color = 0xFF0000
  101.     elseif i < barWidth * 0.66 then
  102.       color = 0xFFFF00
  103.     else
  104.       color = COLOR_SUCCESS
  105.     end
  106.  
  107.     gpu.setForeground(color)
  108.     gpu.set(barX + i, barY, "█")
  109.     os.sleep(0.03)
  110.   end
  111.  
  112.   os.sleep(0.4)
  113.  
  114.   -- System checks
  115.   local checks = {
  116.     {text = "Modem erkannt", status = modem ~= nil},
  117.     {text = "Wireless aktiv", status = modem and modem.isWireless()},
  118.     {text = "Nanomachines verbunden", status = nano ~= nil},
  119.     {text = "Inputs verfuegbar", status = nano and nano.getInputCount() > 0}
  120.   }
  121.  
  122.   local checkY = startY + 14
  123.  
  124.   for i, check in ipairs(checks) do
  125.     os.sleep(0.25)
  126.  
  127.     if check.status then
  128.       gpu.setForeground(COLOR_SUCCESS)
  129.       gpu.set(20, checkY + i - 1, "[✓]")
  130.     else
  131.       gpu.setForeground(COLOR_ERROR)
  132.       gpu.set(20, checkY + i - 1, "[✗]")
  133.     end
  134.  
  135.     gpu.setForeground(COLOR_FG)
  136.     gpu.set(25, checkY + i - 1, check.text)
  137.   end
  138.  
  139.   os.sleep(0.8)
  140.  
  141.   -- Final message with animation
  142.   local readyMsg = ">>> SYSTEM BEREIT <<<"
  143.   gpu.setForeground(COLOR_SUCCESS)
  144.  
  145.   for i = 1, 3 do
  146.     gpu.set(math.floor((80 - #readyMsg) / 2), checkY + 5, readyMsg)
  147.     os.sleep(0.3)
  148.     gpu.set(math.floor((80 - #readyMsg) / 2), checkY + 5, string.rep(" ", #readyMsg))
  149.     os.sleep(0.2)
  150.   end
  151.  
  152.   gpu.set(math.floor((80 - #readyMsg) / 2), checkY + 5, readyMsg)
  153.   os.sleep(1.2)
  154. end
  155.  
  156. -- Check for nanomachines
  157. local function checkNanomachines()
  158.   if not nano then
  159.     term.clear()
  160.     gpu.setForeground(COLOR_ERROR)
  161.     print("╔════════════════════════════════════════╗")
  162.     print("║  FEHLER: Keine Nanomachines gefunden! ║")
  163.     print("╚════════════════════════════════════════╝")
  164.     print("")
  165.     gpu.setForeground(COLOR_FG)
  166.     print("Stelle sicher dass:")
  167.     print("  [1] Du Nanomachines konsumiert hast")
  168.     print("  [2] Sie geladen sind")
  169.     print("  [3] Du eine Wireless Network Card hast")
  170.     print("")
  171.     gpu.setForeground(COLOR_WARNING)
  172.     print("Druecke eine Taste zum Beenden...")
  173.     event.pull("key_down")
  174.     return false
  175.   end
  176.   return true
  177. end
  178.  
  179. -- Server Setup
  180. local function setupServer()
  181.   term.clear()
  182.   gpu.setForeground(COLOR_HEADER)
  183.   print("╔═══════════════════════════════════════════╗")
  184.   print("║    NANOMACHINE CLIENT SETUP               ║")
  185.   print("╚═══════════════════════════════════════════╝")
  186.   print("")
  187.   gpu.setForeground(COLOR_FG)
  188.   print("Server-Adresse eingeben:")
  189.   gpu.setForeground(COLOR_INACTIVE)
  190.   print("(oder Enter druecken fuer Standalone-Modus)")
  191.   print("")
  192.   gpu.setForeground(COLOR_FG)
  193.   io.write("> ")
  194.   SERVER_ADDR = io.read()
  195.  
  196.   if SERVER_ADDR == "" then
  197.     SERVER_ADDR = nil
  198.     print("")
  199.     gpu.setForeground(COLOR_WARNING)
  200.     print("⚠ Standalone-Modus (kein Server)")
  201.     gpu.setForeground(COLOR_INACTIVE)
  202.     print("Profile werden lokal gespeichert")
  203.   else
  204.     print("")
  205.     gpu.setForeground(COLOR_SUCCESS)
  206.     print("✓ Server gesetzt: " .. SERVER_ADDR:sub(1, 8) .. "...")
  207.     gpu.setForeground(COLOR_INACTIVE)
  208.     print("Profile werden auf Server synchronisiert")
  209.   end
  210.  
  211.   gpu.setForeground(COLOR_FG)
  212.   print("")
  213.   print("Taste druecken zum Fortfahren...")
  214.   event.pull("key_down")
  215. end
  216.  
  217. -- Communication
  218. local function sendCommand(command, data)
  219.   if not SERVER_ADDR then return end
  220.  
  221.   local serialized = data and serialization.serialize(data) or nil
  222.   modem.send(SERVER_ADDR, PORT, command, serialized)
  223. end
  224.  
  225. local function requestData(command)
  226.   if not SERVER_ADDR then return nil end
  227.  
  228.   sendCommand(command)
  229.   local timeout = os.time() + 2
  230.  
  231.   while os.time() < timeout do
  232.     local _, _, sender, _, _, cmd, serializedData = event.pull(0.1, "modem_message")
  233.     if cmd and cmd == command .. "_RESPONSE" then
  234.       if serializedData then
  235.         local success, data = pcall(serialization.unserialize, serializedData)
  236.         if success then
  237.           return data
  238.         end
  239.       end
  240.       return {}
  241.     end
  242.   end
  243.  
  244.   return nil
  245. end
  246.  
  247. -- Nanomachine Control
  248. local function updateNanoStatus()
  249.   if not nano then return end
  250.  
  251.   statusData.power = nano.getPowerState()
  252.   statusData.maxPower = nano.getMaxPower()
  253.   statusData.totalInputs = nano.getInputCount()
  254.  
  255.   -- Count active inputs
  256.   statusData.activeInputs = 0
  257.   for i = 1, statusData.totalInputs do
  258.     if nano.getInput(i) then
  259.       statusData.activeInputs = statusData.activeInputs + 1
  260.     end
  261.   end
  262.  
  263.   -- Get active effects
  264.   local effects = nano.getActiveEffects()
  265.   statusData.activeEffects = effects and #effects or 0
  266.   statusData.effects = effects or {}
  267.  
  268.   statusData.lastUpdate = os.time()
  269. end
  270.  
  271. local function setInput(inputId, active)
  272.   if not nano or inputId < 1 or inputId > statusData.totalInputs then
  273.     return false
  274.   end
  275.  
  276.   nano.setInput(inputId, active)
  277.   return true
  278. end
  279.  
  280. local function toggleInput(inputId)
  281.   if not nano then return false end
  282.  
  283.   local currentState = nano.getInput(inputId)
  284.   return setInput(inputId, not currentState)
  285. end
  286.  
  287. local function disableAllInputs()
  288.   if not nano then return end
  289.  
  290.   for i = 1, statusData.totalInputs do
  291.     setInput(i, false)
  292.   end
  293.  
  294.   statusData.currentProfile = nil
  295. end
  296.  
  297. local function getCurrentInputState()
  298.   if not nano then return {} end
  299.  
  300.   local inputs = {}
  301.   for i = 1, statusData.totalInputs do
  302.     if nano.getInput(i) then
  303.       table.insert(inputs, i)
  304.     end
  305.   end
  306.   return inputs
  307. end
  308.  
  309. local function applyInputState(inputs)
  310.   if not nano then return end
  311.  
  312.   -- Disable all first
  313.   disableAllInputs()
  314.  
  315.   -- Enable specified inputs
  316.   for _, inputId in ipairs(inputs) do
  317.     setInput(inputId, true)
  318.   end
  319. end
  320.  
  321. -- Profile Management
  322. local function loadProfiles()
  323.   if SERVER_ADDR then
  324.     local serverProfiles = requestData("GET_PROFILES")
  325.     if serverProfiles then
  326.       profiles = serverProfiles
  327.       return
  328.     end
  329.   end
  330.  
  331.   -- Default profiles if no server or server unavailable
  332.   if #profiles == 0 then
  333.     profiles = {
  334.       {name = "Safe", description = "Nur Regeneration", inputs = {}},
  335.       {name = "Combat", description = "Kampf-Modus", inputs = {}},
  336.       {name = "Mining", description = "Bergbau-Modus", inputs = {}}
  337.     }
  338.   end
  339. end
  340.  
  341. local function saveCurrentAsProfile(name, description)
  342.   local inputs = getCurrentInputState()
  343.  
  344.   local profile = {
  345.     name = name,
  346.     description = description or "Eigenes Profil",
  347.     inputs = inputs,
  348.     created = os.time()
  349.   }
  350.  
  351.   table.insert(profiles, profile)
  352.  
  353.   -- Send to server if connected
  354.   if SERVER_ADDR then
  355.     sendCommand("SAVE_PROFILE", profile)
  356.   end
  357.  
  358.   return true
  359. end
  360.  
  361. local function activateProfile(profileName)
  362.   local profile = nil
  363.   for _, p in ipairs(profiles) do
  364.     if p.name == profileName then
  365.       profile = p
  366.       break
  367.     end
  368.   end
  369.  
  370.   if not profile then
  371.     return false
  372.   end
  373.  
  374.   applyInputState(profile.inputs)
  375.   statusData.currentProfile = profileName
  376.  
  377.   return true
  378. end
  379.  
  380. -- Draw Functions
  381. local function drawHeader(title)
  382.   gpu.setBackground(COLOR_BG)
  383.   gpu.setForeground(COLOR_FX)
  384.   gpu.fill(1, 1, 80, 3, " ")
  385.  
  386.   local fx = "fx-Studios"
  387.   gpu.set(2, 1, fx)
  388.  
  389.   gpu.setForeground(COLOR_HEADER)
  390.   local titleText = "╔═══ " .. title .. " ═══╗"
  391.   gpu.set(math.floor((80 - #titleText) / 2), 2, titleText)
  392.  
  393.   gpu.setForeground(COLOR_INACTIVE)
  394.   gpu.set(70, 1, "v2.0")
  395. end
  396.  
  397. local function drawButton(x, y, text, width, active)
  398.   local bg = active and COLOR_SELECTED or COLOR_BUTTON
  399.   gpu.setBackground(bg)
  400.   gpu.setForeground(COLOR_FG)
  401.  
  402.   local padding = math.floor((width - #text) / 2)
  403.   local buttonText = string.rep(" ", padding) .. text .. string.rep(" ", width - padding - #text)
  404.  
  405.   gpu.set(x, y, buttonText)
  406.   gpu.setBackground(COLOR_BG)
  407. end
  408.  
  409. local function drawStatusBar(y, label, value, maxValue, color)
  410.   gpu.setForeground(COLOR_FG)
  411.   gpu.set(2, y, label .. ":")
  412.  
  413.   local barWidth = 40
  414.   local barX = 25
  415.   local percentage = maxValue > 0 and (value / maxValue) or 0
  416.   local filled = math.floor(barWidth * percentage)
  417.  
  418.   gpu.setForeground(color)
  419.   gpu.set(barX, y, "[" .. string.rep("█", filled) .. string.rep("░", barWidth - filled) .. "]")
  420.  
  421.   gpu.setForeground(COLOR_FG)
  422.   gpu.set(barX + barWidth + 3, y, string.format("%d/%d (%.1f%%)", value, maxValue, percentage * 100))
  423. end
  424.  
  425. -- Main Dashboard Screen
  426. local function drawMainScreen()
  427.   term.clear()
  428.   drawHeader("NANOMACHINE CONTROL CENTER")
  429.  
  430.   gpu.setForeground(COLOR_FG)
  431.  
  432.   -- Status Section
  433.   gpu.setForeground(COLOR_HEADER)
  434.   gpu.set(2, 5, "═══ SYSTEM STATUS ═══")
  435.   gpu.setForeground(COLOR_FG)
  436.  
  437.   drawStatusBar(7, "Power", statusData.power or 0, statusData.maxPower or 100, COLOR_SUCCESS)
  438.  
  439.   gpu.set(2, 9, "Aktive Inputs: " .. (statusData.activeInputs or 0) .. "/" .. (statusData.totalInputs or 0))
  440.   gpu.set(2, 10, "Aktive Effekte: " .. (statusData.activeEffects or 0))
  441.  
  442.   -- Display active effects
  443.   if statusData.effects and #statusData.effects > 0 then
  444.     gpu.setForeground(COLOR_SUCCESS)
  445.     local effectText = table.concat(statusData.effects, ", ")
  446.     if #effectText > 75 then
  447.       effectText = effectText:sub(1, 72) .. "..."
  448.     end
  449.     gpu.set(2, 11, "Effekte: " .. effectText)
  450.     gpu.setForeground(COLOR_FG)
  451.   end
  452.  
  453.   -- Current Profile
  454.   gpu.setForeground(COLOR_HEADER)
  455.   gpu.set(2, 13, "═══ AKTUELLES PROFIL ═══")
  456.   gpu.setForeground(COLOR_FG)
  457.  
  458.   if statusData.currentProfile then
  459.     gpu.setForeground(COLOR_SUCCESS)
  460.     gpu.set(2, 14, "● " .. statusData.currentProfile)
  461.   else
  462.     gpu.setForeground(COLOR_INACTIVE)
  463.     gpu.set(2, 14, "○ Kein Profil aktiv")
  464.   end
  465.  
  466.   -- Server Status
  467.   gpu.setForeground(COLOR_HEADER)
  468.   gpu.set(45, 13, "═══ SERVER ═══")
  469.   gpu.setForeground(COLOR_FG)
  470.  
  471.   if SERVER_ADDR then
  472.     gpu.setForeground(COLOR_SUCCESS)
  473.     gpu.set(45, 14, "● Verbunden")
  474.     gpu.setForeground(COLOR_INACTIVE)
  475.     gpu.set(45, 15, SERVER_ADDR:sub(1, 16) .. "...")
  476.   else
  477.     gpu.setForeground(COLOR_WARNING)
  478.     gpu.set(45, 14, "○ Standalone")
  479.   end
  480.  
  481.   gpu.setForeground(COLOR_FG)
  482.  
  483.   -- Navigation Buttons
  484.   gpu.setForeground(COLOR_HEADER)
  485.   gpu.set(2, 18, "═══ SCHNELLZUGRIFF ═══")
  486.  
  487.   drawButton(2, 20, "1: Profile", 15, false)
  488.   drawButton(19, 20, "2: Manuell", 15, false)
  489.   drawButton(36, 20, "3: Discovery", 15, false)
  490.   drawButton(53, 20, "4: Effekte", 15, false)
  491.  
  492.   drawButton(2, 22, "E: Notaus", 15, false)
  493.   drawButton(19, 22, "S: Speichern", 17, false)
  494.   drawButton(38, 22, "R: Refresh", 15, false)
  495.  
  496.   -- Footer
  497.   gpu.setForeground(COLOR_INACTIVE)
  498.   gpu.set(2, 24, "Q: Beenden")
  499.   gpu.setForeground(COLOR_FX)
  500.   gpu.set(60, 24, "by fxllenfx")
  501. end
  502.  
  503. -- Profile Selection Screen
  504. local function drawProfileScreen()
  505.   term.clear()
  506.   drawHeader("PROFILE")
  507.  
  508.   gpu.setForeground(COLOR_FG)
  509.  
  510.   if not profiles or #profiles == 0 then
  511.     gpu.setForeground(COLOR_WARNING)
  512.     gpu.set(2, 5, "Keine Profile vorhanden")
  513.     gpu.setForeground(COLOR_FG)
  514.     gpu.set(2, 7, "Druecke S um aktuellen Status als Profil zu speichern")
  515.     gpu.set(2, 8, "Druecke B um zurueck zu gehen")
  516.     return
  517.   end
  518.  
  519.   gpu.setForeground(COLOR_HEADER)
  520.   gpu.set(2, 5, "═══ VERFUEGBARE PROFILE ═══")
  521.   gpu.setForeground(COLOR_FG)
  522.  
  523.   for i, profile in ipairs(profiles) do
  524.     if i > scrollOffset and i <= scrollOffset + 12 then
  525.       local y = 7 + (i - scrollOffset - 1)
  526.       local isActive = statusData.currentProfile == profile.name
  527.  
  528.       if isActive then
  529.         gpu.setForeground(COLOR_SUCCESS)
  530.         gpu.set(2, y, "▶ ")
  531.       else
  532.         gpu.setForeground(COLOR_INACTIVE)
  533.         gpu.set(2, y, "  ")
  534.       end
  535.  
  536.       gpu.setForeground(COLOR_FG)
  537.       gpu.set(5, y, string.format("[%d] %s", i, profile.name))
  538.  
  539.       if profile.description then
  540.         gpu.setForeground(COLOR_INACTIVE)
  541.         gpu.set(30, y, "- " .. profile.description)
  542.       end
  543.  
  544.       gpu.setForeground(COLOR_INACTIVE)
  545.       local inputCount = profile.inputs and #profile.inputs or 0
  546.       gpu.set(65, y, "(" .. inputCount .. " inputs)")
  547.     end
  548.   end
  549.  
  550.   -- Instructions
  551.   gpu.setForeground(COLOR_HEADER)
  552.   gpu.set(2, 21, "═══ STEUERUNG ═══")
  553.   gpu.setForeground(COLOR_FG)
  554.   gpu.set(2, 22, "Zahl: Profil aktivieren")
  555.   gpu.set(2, 23, "B: Zurueck")
  556. end
  557.  
  558. -- Manual Control Screen
  559. local function drawManualScreen()
  560.   term.clear()
  561.   drawHeader("MANUELLE STEUERUNG")
  562.  
  563.   gpu.setForeground(COLOR_FG)
  564.  
  565.   if not statusData.totalInputs or statusData.totalInputs == 0 then
  566.     gpu.setForeground(COLOR_WARNING)
  567.     gpu.set(2, 5, "Keine Input-Daten verfuegbar")
  568.     return
  569.   end
  570.  
  571.   gpu.setForeground(COLOR_HEADER)
  572.   gpu.set(2, 5, "═══ INPUT KANAELE ═══")
  573.   gpu.setForeground(COLOR_FG)
  574.  
  575.   local cols = 4
  576.   local maxPerScreen = 40
  577.   local row = 0
  578.  
  579.   for i = 1, math.min(statusData.totalInputs, maxPerScreen) do
  580.     local isActive = nano.getInput(i)
  581.     local col = (i - 1) % cols
  582.     local x = 2 + (col * 19)
  583.     local y = 7 + row
  584.  
  585.     if col == 0 and i > 1 then
  586.       row = row + 1
  587.     end
  588.  
  589.     local status = isActive and " ON" or "OFF"
  590.     local color = isActive and COLOR_SUCCESS or COLOR_INACTIVE
  591.  
  592.     gpu.setForeground(color)
  593.     gpu.set(x, y, string.format("[%2d] %s", i, status))
  594.   end
  595.  
  596.   -- Instructions
  597.   gpu.setForeground(COLOR_HEADER)
  598.   gpu.set(2, 20, "═══ STEUERUNG ═══")
  599.   gpu.setForeground(COLOR_FG)
  600.   gpu.set(2, 21, "Zahl: Input umschalten")
  601.   gpu.set(2, 22, "X: Alle deaktivieren")
  602.   gpu.set(2, 23, "B: Zurueck")
  603. end
  604.  
  605. -- Discovery Screen
  606. local function drawDiscoveryScreen()
  607.   term.clear()
  608.   drawHeader("EFFEKT DISCOVERY")
  609.  
  610.   gpu.setForeground(COLOR_FG)
  611.  
  612.   gpu.setForeground(COLOR_HEADER)
  613.   gpu.set(2, 5, "═══ DISCOVERY MODUS ═══")
  614.   gpu.setForeground(COLOR_FG)
  615.  
  616.   if discoveryActive then
  617.     gpu.setForeground(COLOR_SUCCESS)
  618.     gpu.set(2, 7, "● Discovery laeuft...")
  619.     gpu.setForeground(COLOR_FG)
  620.     gpu.set(2, 9, "Fortschritt: " .. discoveryProgress .. "%")
  621.   else
  622.     gpu.setForeground(COLOR_INACTIVE)
  623.     gpu.set(2, 7, "○ Discovery inaktiv")
  624.   end
  625.  
  626.   gpu.setForeground(COLOR_HEADER)
  627.   gpu.set(2, 12, "═══ STEUERUNG ═══")
  628.   gpu.setForeground(COLOR_FG)
  629.   gpu.set(2, 13, "S: Discovery starten")
  630.   gpu.set(2, 14, "P: Discovery pausieren")
  631.   gpu.set(2, 15, "R: Discovery zuruecksetzen")
  632.   gpu.set(2, 16, "B: Zurueck")
  633.  
  634.   gpu.setForeground(COLOR_WARNING)
  635.   gpu.set(2, 19, "⚠ Warnung: Discovery testet systematisch alle")
  636.   gpu.set(2, 20, "  Input-Kombinationen. Dies kann mehrere Minuten dauern.")
  637. end
  638.  
  639. -- Effects Screen
  640. local function drawEffectsScreen()
  641.   term.clear()
  642.   drawHeader("AKTIVE EFFEKTE")
  643.  
  644.   gpu.setForeground(COLOR_HEADER)
  645.   gpu.set(2, 5, "═══ EFFEKT DETAILS ═══")
  646.   gpu.setForeground(COLOR_FG)
  647.  
  648.   if statusData.effects and #statusData.effects > 0 then
  649.     for i, effect in ipairs(statusData.effects) do
  650.       local y = 7 + i - 1
  651.       if y < 20 then
  652.         gpu.setForeground(COLOR_SUCCESS)
  653.         gpu.set(2, y, "● " .. effect)
  654.       end
  655.     end
  656.   else
  657.     gpu.setForeground(COLOR_INACTIVE)
  658.     gpu.set(2, 7, "Keine aktiven Effekte")
  659.   end
  660.  
  661.   gpu.setForeground(COLOR_HEADER)
  662.   gpu.set(2, 21, "═══ STEUERUNG ═══")
  663.   gpu.setForeground(COLOR_FG)
  664.   gpu.set(2, 22, "B: Zurueck")
  665. end
  666.  
  667. -- Input Handling
  668. local function handleMainInput(char)
  669.   if char == string.byte("1") then
  670.     currentScreen = "profiles"
  671.   elseif char == string.byte("2") then
  672.     currentScreen = "manual"
  673.   elseif char == string.byte("3") then
  674.     currentScreen = "discovery"
  675.   elseif char == string.byte("4") then
  676.     currentScreen = "effects"
  677.   elseif char == string.byte("e") or char == string.byte("E") then
  678.     disableAllInputs()
  679.     updateNanoStatus()
  680.   elseif char == string.byte("s") or char == string.byte("S") then
  681.     term.clear()
  682.     print("Profilname eingeben:")
  683.     local name = io.read()
  684.     if name and name ~= "" then
  685.       print("Beschreibung (optional):")
  686.       local desc = io.read()
  687.       saveCurrentAsProfile(name, desc ~= "" and desc or nil)
  688.       loadProfiles()
  689.     end
  690.   elseif char == string.byte("r") or char == string.byte("R") then
  691.     updateNanoStatus()
  692.     if SERVER_ADDR then
  693.       loadProfiles()
  694.     end
  695.   elseif char == string.byte("q") or char == string.byte("Q") then
  696.     return false
  697.   end
  698.   return true
  699. end
  700.  
  701. local function handleProfileInput(char)
  702.   if char == string.byte("b") or char == string.byte("B") then
  703.     currentScreen = "main"
  704.   elseif char >= string.byte("0") and char <= string.byte("9") then
  705.     local num = char - string.byte("0")
  706.     if profiles[num] then
  707.       activateProfile(profiles[num].name)
  708.       updateNanoStatus()
  709.     end
  710.   end
  711. end
  712.  
  713. local function handleManualInput(char)
  714.   if char == string.byte("b") or char == string.byte("B") then
  715.     currentScreen = "main"
  716.   elseif char == string.byte("x") or char == string.byte("X") then
  717.     disableAllInputs()
  718.     updateNanoStatus()
  719.   elseif char >= string.byte("0") and char <= string.byte("9") then
  720.     local num = char - string.byte("0")
  721.     if num <= statusData.totalInputs then
  722.       toggleInput(num)
  723.       updateNanoStatus()
  724.     end
  725.   end
  726. end
  727.  
  728. local function handleDiscoveryInput(char)
  729.   if char == string.byte("b") or char == string.byte("B") then
  730.     currentScreen = "main"
  731.   elseif char == string.byte("s") or char == string.byte("S") then
  732.     discoveryActive = true
  733.     if SERVER_ADDR then
  734.       sendCommand("START_DISCOVERY")
  735.     end
  736.   elseif char == string.byte("p") or char == string.byte("P") then
  737.     discoveryActive = false
  738.     if SERVER_ADDR then
  739.       sendCommand("PAUSE_DISCOVERY")
  740.     end
  741.   elseif char == string.byte("r") or char == string.byte("R") then
  742.     discoveryProgress = 0
  743.     discoveryActive = true
  744.     if SERVER_ADDR then
  745.       sendCommand("RESET_DISCOVERY")
  746.     end
  747.  
Advertisement
Add Comment
Please, Sign In to add comment