test
This commit is contained in:
parent
43313b3869
commit
13e1a5750a
@ -1,13 +1,43 @@
|
|||||||
local id = os.getComputerID()
|
local id = os.getComputerID()
|
||||||
local status = "idle" -- or "busy", "charging", etc.
|
local label = os.getComputerLabel() or ("Turtle_" .. id)
|
||||||
|
local status = "idle" -- Can be changed based on the turtle's job
|
||||||
|
|
||||||
|
-- Try to open modem
|
||||||
|
local modemOpened = false
|
||||||
|
for _, side in ipairs({"top", "bottom", "left", "right", "front", "back"}) do
|
||||||
|
if peripheral.getType(side) == "modem" then
|
||||||
|
rednet.open(side)
|
||||||
|
modemOpened = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not modemOpened then
|
||||||
|
print("❌ No modem found. Aborting.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Display header
|
||||||
|
term.clear()
|
||||||
|
term.setCursorPos(1, 1)
|
||||||
|
print("Status Broadcaster")
|
||||||
|
print("------------------")
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local msg = {
|
local msg = {
|
||||||
id = id,
|
id = id,
|
||||||
label = os.getComputerLabel() or ("Turtle_" .. id),
|
label = label,
|
||||||
status = status,
|
status = status,
|
||||||
time = os.clock()
|
time = os.clock()
|
||||||
}
|
}
|
||||||
rednet.broadcast(textutils.serialize(msg), "turtle_status")
|
|
||||||
|
local serialized = textutils.serialize(msg)
|
||||||
|
rednet.broadcast(serialized, "turtle_status")
|
||||||
|
|
||||||
|
-- Print to screen
|
||||||
|
term.setCursorPos(1, 5)
|
||||||
|
term.clearLine()
|
||||||
|
print("Sent at: " .. os.date("%H:%M:%S"))
|
||||||
|
|
||||||
sleep(5)
|
sleep(5)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user