-- tower_tablet_addon.lua
local tower_id = 5
local lastMsg = ""
local lang = "de"
local function ensureRednetOpen()
for _, n in ipairs(peripheral.getNames()) do
if peripheral.getType(n):match("modem") then rednet.open(n) break end
end
end
ensureRednetOpen()
local function send(cmd, task)
if rednet.isOpen() then
rednet.send(tower_id,{cmd=cmd,task=task})
lastMsg = task
print("Letzte Aktion: "..lastMsg)
end
end
while true do
local e,key = os.pullEvent("key")
if key==keys.one then send("toggle","power_toggle")
elseif key==keys.two then send("toggle","alarm")
elseif key==keys.three then send("toggle","door_main")
elseif key==keys.q then break end
end