Advertisement
samuelask

Hologram

Mar 8th, 2025 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. -- Base Station Script for Kino Drone (Holographic Rendering)
  2. local component = require("component")
  3. local event = require("event")
  4. local term = require("term")
  5. local modem = component.modem
  6. local hologram = component.hologram
  7. hologram.clear()
  8. local scan_data = {} -- Holds x, y, z, density values
  9.  
  10.  
  11.  
  12. -- Configuration
  13. local kino_address = "a1a5a0ee-4ccf-45e7-961b-96ce5afc068c" -- Address of the Kino drone
  14. modem.open(123) -- Open communication port
  15.  
  16. local function debug(msg)
  17.     print("[DEBUG] " .. msg)
  18. end
  19.  
  20. -- ✅ Increase hologram scale (Fixes tiny display issue)
  21. hologram.setScale(3)
  22.  
  23. -- Main loop
  24. print("Base Station active. Waiting for Kino data...")
  25. while true do  
  26.     local _, _, sender, _, _, command, data = event.pull("modem_message")
  27.  
  28.     if command == "debug" then
  29.         print("[Kino] " .. data)
  30.     elseif command == "scan_data" then
  31.         lastUpdateTime = os.time()  -- ✅ Reset timeout when receiving new data
  32.         -- ✅ Convert received string back into a table
  33.         for x, y, z, d in string.gmatch(data, "([^,]+),([^,]+),([^,]+),([^,]+)") do
  34.             local tx = tonumber(x) + 5
  35.             local ty = tonumber(y) + 7
  36.             local tz = tonumber(z) + 5
  37.             local density = tonumber(d)
  38.  
  39.             if density and density > 0 then
  40.                 -- ✅ Store data for future use
  41.                 local key = string.format("%d,%d,%d", tx, ty, tz)
  42.                 scan_data[key] = {tx, ty, tz, density}
  43.                
  44.                 hologram.set(tx, ty, tz, 1)
  45.                 debug("✅ Placed block at: HX=" .. tx .. " HY=" .. ty .. " HZ=" .. tz)
  46.             else
  47.                 debug("⚠️ Invalid data format: " .. x .. "," .. y .. "," .. z .. "," .. d)
  48.             end
  49.         end
  50.     end
  51. end
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement