Advertisement
minecraft_storm

mainControl

Jul 3rd, 2025 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. -- display.lua
  2. local modem = peripheral.find("modem") or error("No modem found")
  3. local monitor = peripheral.find("monitor") or error("No monitor found")
  4. rednet.open(peripheral.getName(modem))
  5.  
  6. monitor.setTextScale(0.5)
  7.  
  8. local tasks = {}
  9. local taskId = 0
  10.  
  11. function drawUI()
  12.     monitor.clear()
  13.     monitor.setCursorPos(1, 1)
  14.     monitor.write("== Task Dashboard ==")
  15.     local line = 3
  16.     for id, task in pairs(tasks) do
  17.         monitor.setCursorPos(1, line)
  18.         monitor.write("#" .. id .. " " .. task.task)
  19.         line = line + 1
  20.         monitor.setCursorPos(2, line)
  21.         monitor.write("At: " .. math.floor(task.location.x) .. "," .. math.floor(task.location.z))
  22.         line = line + 1
  23.         monitor.setCursorPos(2, line)
  24.         monitor.write("Progress: " .. (task.progress or 0) .. "%")
  25.         line = line + 2
  26.     end
  27. end
  28.  
  29. -- Simulate turtle progress (you’ll later replace this with real progress updates)
  30. function simulateProgress(id)
  31.     while tasks[id] and tasks[id].progress < 100 do
  32.         tasks[id].progress = tasks[id].progress + 10
  33.         drawUI()
  34.         sleep(2)
  35.     end
  36. end
  37.  
  38. -- Main loop
  39. while true do
  40.     local sender, msg = rednet.receive()
  41.     local task = textutils.unserialize(msg)
  42.     if task and task.task then
  43.         taskId = taskId + 1
  44.         task.progress = 0
  45.         tasks[taskId] = task
  46.         rednet.send(sender, "Task #" .. taskId .. " accepted")
  47.         drawUI()
  48.         -- Simulate progress for now
  49.         parallel.waitForAny(
  50.             function() simulateProgress(taskId) end
  51.         )
  52.     end
  53. end
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement