Advertisement
samuelask

Tablet

Mar 8th, 2025 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. -- Tablet UI Script for Kino Control
  2. local component = require("component")
  3. local event = require("event")
  4. local term = require("term")
  5. local modem = component.modem
  6. local gpu = component.gpu
  7.  
  8. -- Configuration
  9. local kino_address = "a1a5a0ee-4ccf-45e7-961b-96ce5afc068c" -- Address of the Kino
  10. local fine_motor_control = false -- Default: Disabled
  11. modem.open(123)
  12.  
  13. -- UI Drawing Function
  14. local function draw_ui()
  15.     term.clear()
  16.     print("Kino Control Tablet")
  17.     print("[W] Forward  [S] Backward")
  18.     print("[A] Left     [D] Right")
  19.     print("[Q] Up       [E] Down")
  20.     print("[1] Normal Scan  [2] Entity Scan  [3] Detailed Scan")
  21.     print("[SPACE] Start Scan")
  22.      print("[F] Toggle Fine Motor Control [" .. (fine_motor_control and "ON" or "OFF") .. "]")
  23. end
  24.  
  25. draw_ui()
  26.  
  27. -- Function to send commands to the Kino
  28. local function send_command(command, value)
  29.     modem.send(kino_address, 123, command, value)
  30. end
  31.  
  32. -- Keyboard Input Listener
  33. local function key_listener(_, _, char, code, _)
  34.     local key = string.char(char)
  35.     if key == "w" then send_command("move", "forward")
  36.     elseif key == "s" then send_command("move", "backward")
  37.     elseif key == "a" then send_command("move", "left")
  38.     elseif key == "d" then send_command("move", "right")
  39.     elseif key == "q" then send_command("move", "up")
  40.     elseif key == "e" then send_command("move", "down")
  41.     elseif key == "1" then send_command("set_scan_mode", "normal")
  42.     elseif key == "2" then send_command("set_scan_mode", "entity")
  43.     elseif key == "3" then send_command("set_scan_mode", "detailed")
  44.     elseif code == 57 then
  45.         if fine_motor_control then
  46.             print("[❌] Scan BLOCKED: Fine Motor Control is ENABLED!")
  47.         else
  48.             send_command("scan", "")
  49.         end
  50.     elseif key == "f" then
  51.         fine_motor_control = not fine_motor_control
  52.         send_command("fine_control", fine_motor_control and "on" or "off")
  53.         draw_ui()
  54.         print("[🔧] Fine Motor Control: " .. (fine_motor_control and "ENABLED" or "DISABLED"))   
  55.     end
  56. end
  57.  
  58. event.listen("key_down", key_listener)
  59.  
  60. print("Tablet UI running. Use W/A/S/D/Q/E to move, 1/2/3 to change scan mode, SPACE to scan, F to toggle Fine Motor Control.")
  61. while true do
  62.     os.sleep(1)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement