Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tablet UI Script for Kino Control
- local component = require("component")
- local event = require("event")
- local term = require("term")
- local modem = component.modem
- local gpu = component.gpu
- -- Configuration
- local kino_address = "a1a5a0ee-4ccf-45e7-961b-96ce5afc068c" -- Address of the Kino
- local fine_motor_control = false -- Default: Disabled
- modem.open(123)
- -- UI Drawing Function
- local function draw_ui()
- term.clear()
- print("Kino Control Tablet")
- print("[W] Forward [S] Backward")
- print("[A] Left [D] Right")
- print("[Q] Up [E] Down")
- print("[1] Normal Scan [2] Entity Scan [3] Detailed Scan")
- print("[SPACE] Start Scan")
- print("[F] Toggle Fine Motor Control [" .. (fine_motor_control and "ON" or "OFF") .. "]")
- end
- draw_ui()
- -- Function to send commands to the Kino
- local function send_command(command, value)
- modem.send(kino_address, 123, command, value)
- end
- -- Keyboard Input Listener
- local function key_listener(_, _, char, code, _)
- local key = string.char(char)
- if key == "w" then send_command("move", "forward")
- elseif key == "s" then send_command("move", "backward")
- elseif key == "a" then send_command("move", "left")
- elseif key == "d" then send_command("move", "right")
- elseif key == "q" then send_command("move", "up")
- elseif key == "e" then send_command("move", "down")
- elseif key == "1" then send_command("set_scan_mode", "normal")
- elseif key == "2" then send_command("set_scan_mode", "entity")
- elseif key == "3" then send_command("set_scan_mode", "detailed")
- elseif code == 57 then
- if fine_motor_control then
- print("[❌] Scan BLOCKED: Fine Motor Control is ENABLED!")
- else
- send_command("scan", "")
- end
- elseif key == "f" then
- fine_motor_control = not fine_motor_control
- send_command("fine_control", fine_motor_control and "on" or "off")
- draw_ui()
- print("[🔧] Fine Motor Control: " .. (fine_motor_control and "ENABLED" or "DISABLED"))
- end
- end
- event.listen("key_down", key_listener)
- 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.")
- while true do
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement