Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- display.lua
- local modem = peripheral.find("modem") or error("No modem found")
- local monitor = peripheral.find("monitor") or error("No monitor found")
- rednet.open(peripheral.getName(modem))
- monitor.setTextScale(0.5)
- local tasks = {}
- local taskId = 0
- function drawUI()
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("== Task Dashboard ==")
- local line = 3
- for id, task in pairs(tasks) do
- monitor.setCursorPos(1, line)
- monitor.write("#" .. id .. " " .. task.task)
- line = line + 1
- monitor.setCursorPos(2, line)
- monitor.write("At: " .. math.floor(task.location.x) .. "," .. math.floor(task.location.z))
- line = line + 1
- monitor.setCursorPos(2, line)
- monitor.write("Progress: " .. (task.progress or 0) .. "%")
- line = line + 2
- end
- end
- -- Simulate turtle progress (you’ll later replace this with real progress updates)
- function simulateProgress(id)
- while tasks[id] and tasks[id].progress < 100 do
- tasks[id].progress = tasks[id].progress + 10
- drawUI()
- sleep(2)
- end
- end
- -- Main loop
- while true do
- local sender, msg = rednet.receive()
- local task = textutils.unserialize(msg)
- if task and task.task then
- taskId = taskId + 1
- task.progress = 0
- tasks[taskId] = task
- rednet.send(sender, "Task #" .. taskId .. " accepted")
- drawUI()
- -- Simulate progress for now
- parallel.waitForAny(
- function() simulateProgress(taskId) end
- )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement