0
Web IDE main
4 commitsoaky Update teleport-remote
0eb74a88 2026-09-25
main | 2026-09-25 |
Overview
MITTeleport Remote
Quick Install on your ComputerCraft device
Type this command in the terminal:
hub get teleport-remote
main.lua main
--[[
=========================================================================
Teleport-Fernbedienung - laeuft auf dem Advanced Ender Pocket Computer
=========================================================================
Zwei Buttons - "END" und "HOME" - senden per Funk (rednet) eine
Auswahl an beide Teleport-Gates (siehe teleport_gate.lua). Die nutzen
das eingebaute Ender-Modem: unbegrenzte Reichweite, funktioniert auch
nach der Teleportation ins End weiter (normale Wireless-Modems wuerden
die Verbindung beim Dimensionswechsel verlieren).
Keine feste Empfaenger-Adresse noetig - wird per rednet.broadcast an
alle lauschenden Gates geschickt; jedes entscheidet selbst, ob es sich
angesprochen fuehlt (siehe MY_DESTINATION in teleport_gate.lua).
Die unterste Zeile ist eine feste Statuszeile: bestaetigt jeden
gesendeten Klick ("Gesendet: END") oder zeigt den genauen Fehlertext,
falls beim Senden etwas schiefgeht - damit ein Fehlschlag sichtbar
bleibt, statt das Programm lautlos abstuerzen zu lassen.
Starten mit: teleport_remote
=========================================================================
]]
local PROTOCOL = "teleport_select"
local modem = peripheral.find("modem", function(name, wrapped) return wrapped.isWireless() end)
if not modem then
error("Kein DRAHTLOSES Modem gefunden! Dieses Programm braucht den Advanced Ender Pocket Computer (eingebautes Ender-Modem).")
end
rednet.open(peripheral.getName(modem))
------------------------------------------------------------------------
-- Reine Logik (ohne Bildschirm-/Funk-Zugriff - testbar)
------------------------------------------------------------------------
-- Nutzbarer Bereich ist oben/unten in zwei gleich grosse Haelften
-- geteilt (die letzte Zeile ist als Statuszeile reserviert, siehe unten).
-- Gibt zurueck, welches Ziel ein Klick auf Zeile 'y' bei nutzbarer
-- Hoehe 'usableH' ausloesen wuerde.
local function whichButton(y, usableH)
local half = math.floor(usableH / 2)
if y <= half then return "end" end
return "home"
end
------------------------------------------------------------------------
-- Anzeige
------------------------------------------------------------------------
local status = { text = "Bereit.", color = colors.gray }
local function setStatus(text, color)
status = { text = text, color = color or colors.gray }
end
local function drawHalf(y1, y2, w, label, bg)
term.setBackgroundColor(bg)
for y = y1, y2 do
term.setCursorPos(1, y)
term.clearLine()
end
term.setTextColor(colors.white)
local textY = math.floor((y1 + y2) / 2)
term.setCursorPos(math.max(1, math.floor((w - #label) / 2) + 1), textY)
term.write(label)
end
local function drawStatus(w, h)
term.setCursorPos(1, h)
term.setBackgroundColor(colors.black)
term.clearLine()
term.setTextColor(status.color)
term.write(status.text:sub(1, w))
end
local function render()
local w, h = term.getSize()
local usableH = h - 1 -- letzte Zeile ist die Statuszeile
local half = math.floor(usableH / 2)
term.setBackgroundColor(colors.black)
term.clear()
drawHalf(1, half, w, "END", colors.purple)
drawHalf(half + 1, usableH, w, "HOME", colors.green)
drawStatus(w, h)
end
-- Kurzes visuelles Feedback: Haelfte kurz aufblitzen lassen.
local function flash(y1, y2, w)
term.setBackgroundColor(colors.white)
for y = y1, y2 do
term.setCursorPos(1, y)
term.clearLine()
end
sleep(0.15)
end
------------------------------------------------------------------------
-- Hauptschleife
------------------------------------------------------------------------
render()
while true do
local _, _, x, y = os.pullEvent("mouse_click")
local w, h = term.getSize()
local usableH = h - 1
if y <= usableH then
local half = math.floor(usableH / 2)
local destination = whichButton(y, usableH)
if destination == "end" then
flash(1, half, w)
else
flash(half + 1, usableH, w)
end
-- Senden ist gegen Fehler abgesichert, statt das Programm bei einem
-- Problem (z.B. Modem gerade nicht bereit) lautlos abstuerzen zu lassen.
local ok, err = pcall(rednet.broadcast, { destination = destination }, PROTOCOL)
if ok then
setStatus(("Gesendet: %s"):format(destination:upper()), colors.lime)
else
setStatus("Fehler: " .. tostring(err), colors.red)
end
end
render()
end Usage
Once installed with hub get teleport-remote, run:
teleport-remoteCareful what you run: This script was written by oaky, not by us.
It runs with full access to the computer you install it on — it can read and delete files there.
Read it before you run it.
About
No description provided.
MIT License
★ 0 stars
0 in-game downloads
Hardware Targets
computer