Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Copyright 2023 © Roberto "ResaloliPT" Pires
- local builders = {}
- function getBuilders()
- local buildings = colony.getBuildings()
- local count = 1
- for i,v in ipairs(buildings) do
- if v.type == 'builder' then
- builders[count] = v
- count = count + 1
- end
- end
- end
- function drawSelection()
- local selectedNum = nil;
- local selected = false
- term.clear()
- term.setCursorPos(1,1)
- print("Select a builder:")
- for i,v in pairs(builders) do
- print(i .. ": " .. v.name)
- end
- while selected == false do
- term.write(">")
- selectedNum = read()
- if builders[tonumber(selectedNum)] == nil then
- print("Try Again:")
- else
- selected = true
- end
- end
- drawBuilderRequests(builders[tonumber(selectedNum)])
- end
- function drawBuilderRequests(builder)
- term.clear()
- term.setCursorPos(1,1)
- local filteredResources = {}
- local builderResources = colony.getBuilderResources(builder.location)
- for i,v in ipairs(builderResources) do
- if (v.status == "DONT_HAVE" or v.status == "NEED_MORE") and
- ((v.item.maxCount - (v.delivering)) > 0) then
- --table.insert(filteredResources, v)
- end
- textutils.pagedPrint(textutils.serialise(v))
- end
- print("'" .. builder.name .. "' Requires:")
- local finalText = {}
- for i,v in ipairs(filteredResources) do
- local remainingCount = (v.item.maxCount - (v.delivering))
- table.insert(finalText, remainingCount .. " of " .. v.item.displayName)
- end
- textutils.pagedTabulate(finalText)
- os.pullEvent("key")
- end
- -- Program Exec
- getBuilders()
- while true do
- drawSelection()
- sleep(1)
- end
Add Comment
Please, Sign In to add comment