Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --todo
- --multi monitor support
- -- scaling text dependant upon screen size.
- function distance(pos,target)
- if pos == nil then
- return "P"
- elseif target == nil then
- return "T"
- end
- return math.floor(math.sqrt(math.pow(target.x - pos.x, 2) + math.pow(target.y - pos.y, 2) + math.pow(target.z - pos.z, 2)) )
- end
- function round(num,places)
- mult = 10^places
- return math.floor(num * mult + 0.5)/mult
- end
- function direction(pos, target)
- local dx, dz = target.x - pos.x, target.z - pos.z
- dir ="X"
- if dx^2 + dz^2 > 0 then
- local heading = math.atan2(dz, dx)
- local octant = math.floor(8*heading/(2*math.pi) + 8 + 0.5)%8
- dir = compass[octant + 1]
- end
- if pos.y > target.y then
- return dir .. " \\/"
- elseif pos.y < target.y then
- return dir .. " /\\"
- else
- return dir .. " O"
- end
- end
- function myErrorHandler(err)
- print("Error: ", err)
- end
- function jobFromEvent()
- end
- function saveConfig()
- config.requesterList = requesterList
- config.colonyInfo = monitorColonyInfo
- config.builderResourceInfo = showBuilderResourceInfo
- config.delay = delay
- config.arShowAllResourceRequests = arShowAllResourceRequests
- config.owner = owner
- config.doRequests = doRequests
- config.microManage = microManage
- config.chestConfig = chestConfig
- config.defaultSide = "minecraft:chest_0"
- config.showJobInfo = showJobInfo
- --for i,c in pairs(config) do
- -- debugText(c)
- --end
- file = fs.open("managerConfig.lua","w")
- file.write(textutils.serialize(config))
- file.close()
- end
- function message(t,p)
- if p ~= nil then
- chat.sendMessageToPlayer(t,p)
- else
- debugText(t)
- end
- end
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- --m.clear()
- --m.setCursorPos(1,1)
- end
- function debugText(t)
- if m then
- term.redirect(termInstance)
- print(t)
- term.redirect(m[1])
- else
- print(t)
- end
- end
- function hasValue(tab,val,keySearch)
- if tab ~= nil and val ~= nil then
- for k,v in pairs(tab) do
- if keySearch then
- if k == val then
- return true
- end
- else
- if v == val then
- return true
- end
- end
- end
- end
- return false
- end
- --currently unused?!?!
- function setDisplayObjective(val)
- showRequestInfo = false
- showJobInfo = false
- showResearchInfo = false
- if val == 0 then
- showRequestInfo = true
- elseif val == 1 then
- showJobInfo = true
- elseif val == 2 then
- showResearchInfo = true
- end
- end
- function updateString(id, str, x, y, c, centered)
- ar.clearElement(id)
- if centered then
- ar.drawCenteredStringWithId(id, str, x, y, c)
- else
- ar.drawStringWithId(id, str, x, y, c)
- end
- end
- lastActiveQueueCount = 0
- lastQueueCount = 0
- lastNeededCount = 0
- function showAR()
- spacing = 10
- yMod = 60
- --ar.clear()
- updateString("time",formatedTime(),800,10,color, true)
- if ardata.raid then
- updateString("raid","RAID IN PROGRESS", 800, 100, notifyColor, true)
- end
- if ardata.idle > 0 then
- updateString("idle","Idle Count: " .. ardata.idle, 10, yMod, notifyColor)
- else
- updateString("idle","Idle Count: " .. ardata.idle, 10, yMod, color)
- end
- yMod = yMod + spacing
- updateString("pop","Population: " .. ardata.popCount .. " / " .. ardata.totalHousing, 10, yMod, color)
- yMod = yMod + spacing
- updateString("children","Children: " .. ardata.children, 10, yMod, color)
- yMod = yMod + spacing
- updateString("sleeping","Sleeping: " .. ardata.sleeping .. " / " .. ardata.sleepingMax, 10, yMod, color)
- yMod = yMod + spacing
- --Research Info
- if ardata.research.currentAmount < ardata.research.max then
- updateString("research","Research: " .. ardata.research.currentAmount .. " / " .. ardata.research.max, 10, yMod, notifyColor)
- else
- updateString("research","Research: " .. ardata.research.currentAmount .. " / " .. ardata.research.max, 10, yMod, color)
- end
- --Building Queue
- yMod = yMod + spacing
- if ardata.activeBuildCount < ardata.builderCount then
- updateString("buildcount","Buildings In Progress: " .. ardata.activeBuildCount .. " / " .. ardata.builderCount, 10, yMod, notifyColor)
- else
- updateString("buildcount","Buildings In Progress: " .. ardata.activeBuildCount .. " / " .. ardata.builderCount, 10, yMod, headerColor)
- end
- --for i=1, lastActiveQueueCount do
- -- ar.clearElement("activequeue"..i)
- --end
- -- r = 01
- -- for i=1, #ardata.buildQueue do
- -- if ardata.buildQueue[i].queued ~= true then
- -- yMod = yMod + spacing
- -- r = r + 1
- -- updateString("activequeue"..r," " .. ardata.buildQueue[i].name .. ardata.buildQueue[i].toLevel, 10, yMod, color)
- -- end
- -- end
- -- lastActiveQueueCount = r
- yMod = yMod + spacing
- updateString("buildqueuelabel","Buildings Queued: " .. ardata.totalQueueCount, 10, yMod, headerColor)
- -- for i=1, lastQueueCount do
- -- ar.clearElement("buildqueue"..i)
- -- end
- -- r = 0
- -- for i=1, #ardata.buildQueue do
- -- if ardata.buildQueue[i].queued then
- -- yMod = yMod + spacing
- -- r = r + 1
- -- updateString("buildqueue"..r," " .. ardata.buildQueue[i].name, 10, yMod, color)
- -- end
- -- end
- -- lastQueueCount = r
- --Resource Queue
- if doRequests then
- ar.clearElement("disabledInfo")
- yMod = yMod + spacing
- if #ardata.neededItems > 0 then
- updateString("resourcelabel","Resourses Needed: ", 10, yMod, headerColor)
- else
- updateString("resourcelabel","Resourses Needed: ", 10, yMod, color)
- end
- alertStates = {"No Recipe","Missing Items to Craft","Waiting On CPU's","Unable to Craft"}
- for i=1, lastNeededCount do
- ar.clearElement("needed"..i)
- end
- r = 0
- for i=1, #ardata.neededItems do
- if arShowAllResourceRequests then
- yMod = yMod + spacing
- if hasValue(alertStates, ardata.neededItems[i].status) then iColor = warnColor
- else iColor = color end
- r = r + 1
- updateString("needed" .. r," " .. ardata.neededItems[i].displayName .. " " .. ardata.neededItems[i].count .. " " .. ardata.neededItems[i].status, 10, yMod, iColor)
- else
- if hasValue(alertStates,ardata.neededItems[i].status) then
- yMod = yMod + spacing
- r = r + 1
- updateString("needed" .. r," " .. ardata.neededItems[i].displayName .. " " .. ardata.neededItems[i].count .. " " .. ardata.neededItems[i].status, 10, yMod, color)
- end
- end
- end
- lastNeededCount = r
- else
- yMod = yMod + spacing
- updateString("disabledInfo","Resource Manager disabled", 10, yMod, color)
- end
- -- --Citizen Heath
- -- pPos = playerDetector.getPlayerPos("RedStoner_Pro")
- -- if pPos ~= nil then
- -- --debugText(textutils.serialize(pPos))
- --
- -- for i=1, #ardata.health do
- -- cit = ardata.health[i]
- -- lColor = color
- -- healthPercent = round((cit.health / cit.maxHealth)* 100,1)
- --
- -- if healthPercent < 80 then
- -- lColor = warnColor
- -- end
- -- if healthPercent < 50 then
- -- lColor = notifyColor
- -- end
- -- ar.drawRightboundString(cit.name .. " HP: " .. healthPercent .. "%" .. direction(pPos,cit.location) .. " D:" .. distance(pPos,cit.location), -10, -30 - ((i-1) * spacing), lColor)
- -- end
- -- --ar.drawRightboundString(tostring(direction(pPos,{x= 2382, z= 5662, y= 71})) , -10, 150, notifyColor)
- --
- -- --Citizens sleeping info
- -- for i=1, #ardata.sleep do
- -- yMod = -30 - ((i-1)*20)
- -- cit = ardata.sleep[i]
- -- ar.drawString(cit.name .. " " .. direction(pPos,cit.location) .. " D:" .. distance(pPos,cit.location), 100, yMod ,color)
- -- end
- end
- function availableCPUs()
- cpus = me.getCraftingCPUs()
- available = 0
- if cpus then
- for _,cpu in pairs(cpus) do
- if cpu.isBusy == false then
- available = available + 1
- end
- end
- end
- return available
- end
- function bootCycle()
- print("Doing Boot Delay")
- os.sleep(15)
- end
- function filterRequests(v)
- for i=1, #requesterList do
- if string.find(v.target, requesterList[i]) then
- --debugText(v.target .. " is on the list")
- return true
- end
- end
- end
- function formatedTime()
- theTime = os.time()
- hour = math.floor(theTime)
- minutes = math.floor(60 * (theTime%1))
- if minutes < 10 then
- minutes = "0"..minutes
- end
- return hour .. ":" .. minutes
- end
- function checkConfigValues()
- doSave = false
- if requesterList == nil then
- requesterList = {"Builder","Miner", "Library Student", "Request System", "Teacher"}
- doSave = true
- end
- if monitorColonyInfo == nil then
- monitorColonyInfo = true
- doSave = true
- end
- if arShowAllResourceRequests == nil then
- arShowAllResourceRequests = true
- doSave = true
- end
- if showBuilderResourceInfo == nil then
- showBuilderResourceInfo = false
- doSave = true
- end
- if delay == nil then
- delay = 1
- doSave = true
- end
- if doRequest == nil then
- doRequests = true
- doSave = true
- end
- if microManage == nil then
- microManage = false
- doSave = true
- end
- if chestConfig == nil then
- chestConfig = {
- {{x=0,y=0,z=0}, "minecraft:chest_1"},
- {{x=0,y=0,z=0}, "minecraft:chest_2"},
- {{x=0,y=0,z=0}, "minecraft:chest_3"},
- {{x=0,y=0,z=0}, "minecraft:chest_4"},
- }
- doSave = true
- end
- if defaultSide == nil then
- defaultSide = "minecraft:chest_0"
- doSave = true
- end
- if showJobInfo == nil then
- showJobInfo = true
- doSave = true
- end
- if doSave then
- saveConfig()
- end
- end
- function getPushDirection(tName, directionName)
- --first find the citizens info
- for k,v in pairs(colony.getCitizens()) do
- --check if they are a worker
- if v.work ~= nil then
- --check if this is the citizen we want to check sides for
- --debugText("Comparing - " .. string.lower(v.work.type .. " " .. v.name) .. " to " .. string.lower(tName))
- if string.lower(v.work.type .. " " .. v.name) == string.lower(tName) then
- --check if they have an assigned direction.
- wLoc = v.work.location
- --debugText("Found Matching citizen\nComparing - " .. wLoc.x .. " " .. wLoc.y .. " " .. wLoc.z )
- for _,ent in pairs(chestConfig) do
- pos = ent[1]
- --debugText("To - " .. pos.x .. " " .. pos.y .. " " .. pos.z)
- if wLoc.x == pos.x and wLoc.y == pos.y and wLoc.z == pos.z then
- --debugText("foud matching coords on side - " .. ent[2])
- directionName = ent[2]
- break
- end
- end
- return directionName
- end
- end
- end
- --debugText("Falling back to default side")
- return directionName
- end
- --monitormanager start
- function init()
- print("Initializing monManager")
- mData = {}
- if fs.exists("monitorConfig.lua") then
- mConfig = loadMConfig()
- end
- checkMConfig()
- print("Config confirmed. \nNum monitors - " .. #m)
- for i=1, #m do
- tData = {peripheral = m[i], name = peripheral.getName(m[i]), buttons = {}}
- m[i].clear()
- m[i].setCursorPos(1,1)
- --m[i].setTextScale(.5)
- print("Adding " .. tData.name)
- mData[i] = tData
- end
- end
- function loadMConfig()
- file = fs.open("monitorConfig.lua","r")
- content = file.readAll()
- file.close()
- return textutils.unserialize(content)
- end
- function saveMConfig()
- file = fs.open("monitorConfig.lua","w")
- file.write(textutils.serialize(mConfig))
- file.close()
- end
- function checkMConfig()
- for k,v in pairs(m) do
- if mConfig[k] == nil then
- mConfig[k] = {true, true, true, true, false}
- end
- end
- saveMConfig()
- end
- function showButtons(dIndex)
- mData[dIndex].buttons = {}
- mon = mData[dIndex].peripheral
- --buttons = {"Colony", "Requests", "Queue", "Research", "Citizens"}
- buttons = {"Col", "Req", "Que", "Res", "Cit"}
- --get size to try to space evenly
- x,by = mon.getSize()
- tLength = (#buttons * 4) - 1
- remainingSpace = x - tLength
- extraSpacing = remainingSpace / #buttons + 1
- floatingSpacing = remainingSpace % #buttons + 1
- --print("Available Width - " .. x .. "\nTotal Length - " .. tLength .. "\nRemaining Space - ".. remainingSpace .. "\nExtraSpacing - ".. extraSpacing .. "\nFloating Spacing - ".. floatingSpacing)
- --check if we can add extra spacing
- if extraSpacing >= 1 then
- --Add in extra spacing
- end
- --_,by = mon.getCursorPos()
- lastX = 1 + math.floor(floatingSpacing/2);
- for k,v in pairs(buttons) do
- --add an extra space if there is a remainder left
- xSpace = math.floor(extraSpacing)
- bx = lastX + xSpace
- -- add one here to add a space between ones in the middle
- lastX = bx + 1
- --push button's coords to data structure
- table.insert(mData[dIndex].buttons,{x1 = bx, x2 = bx+2, y=by})
- --set colors based on current value
- tc = colors.white
- bc = colors.red
- if mConfig[dIndex][k] == true then
- tc = colors.white
- bc = colors.green
- end
- --print the button to the monitor
- mon.setCursorPos(bx, by)
- mon.setBackgroundColor(bc)
- mon.setTextColor(tc)
- mon.write(v)
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.write(v)
- end
- function getButton(mon,x,y)
- for k,v in pairs(mon.buttons) do
- if y == v.y and x >= v.x1 and x <= v.x2 then
- return k
- end
- end
- return 0
- end
- function getMonByName(n)
- for k,v in pairs(mData) do
- if v.name == n then
- return k
- end
- end
- end
- function getConfigButton(x,y)
- end
- function printConfigButtons()
- end
- function getButtonClick()
- lx = 0
- ly = 0
- while true do
- timerId = os.startTimer(.5)
- while true do
- event, p1, x, y = os.pullEvent()
- if event == "monitor_touch" and (x ~= lx and y ~= ly) then
- --check if there is a button at that location
- mon = getMonByName(p1)
- bIndex = getButton(mData[mon],x,y)
- if bIndex ~= 0 then
- --toggleSection for this monitor based on button clicked
- mConfig[mon][bIndex] = not mConfig[mon][bIndex]
- saveMConfig()
- --debugText( "Set - " .. bIndex .. " to " .. tostring(mConfig[mon][bIndex]))
- showButtons(mon)
- --try to prevent double event detection
- lx = x
- ly = y
- break
- end
- elseif event == "timer" then
- --check if we have the timer event
- if p1 == timerId then
- --debugText("timer")
- lx = 0
- ly = 0
- break
- end
- elseif event == "mouse_click" then
- bIndex = getConfigButton(x,y)
- end
- end
- end
- end
- function makeDashes(mId)
- x,y = mId.getSize()
- t = ""
- for i=1, x do
- t = t .. "-"
- end
- return t
- end
- function addDashes(s,c)
- return s:gsub("%^d", c)
- end
- --monman end
- function main()
- while true do
- ardata = {}
- outputText = ""
- if doRequests then
- requestText = "^d\nColony Request Manager\n^d\n"
- requests = colony.getRequests()
- for _,v in pairs(requests) do
- --filter only wanted requests
- if (v.target ~= nil) then
- if filterRequests(v) then
- --check if this is a new request
- --v.items[1].name
- --debugText(v.target .. " " .. v.name .. " " .. v.count)
- testName = v.target .. v.name .. v.count
- if savedRequests[testName] == nil then
- --add if not
- savedRequests[testName] = {}
- savedRequests[testName].name = v.items[1].name
- savedRequests[testName].displayName = v.items[1].displayName
- savedRequests[testName].count = v.count
- savedRequests[testName].target = v.target
- savedRequests[testName].count = v.count
- savedRequests[testName].filled = false
- savedRequests[testName].crafting = false
- --dbtext = dbtext .. "Added Key- " .. testName .. "\n"
- end
- end
- end
- end
- rmKeys = {}
- --Check for completed requests that are still saved.
- for savedKey,savedVal in pairs(savedRequests) do
- foundMatch = false
- for reqKey, reqVal in pairs(requests) do
- if reqVal.target ~= nil then
- testName = reqVal.target .. reqVal.name .. reqVal.count
- if testName == savedKey then
- foundMatch = true
- break
- end
- end
- end
- if foundMatch == false then
- rmKeys[#rmKeys +1] = savedKey
- end
- end
- --Remove completed requests
- for _,v in pairs(rmKeys) do
- savedRequests[v] = nil
- end
- --Query the ME system for the requested item
- ardata.neededItems = {}
- cpuCount = availableCPUs()
- for _,v in pairs(savedRequests) do
- --Check if request has been handled already
- if not v.filled then
- meItemInfo = me.getItem({name=v.name})
- --if nil we may just be out of items
- if meItemInfo == nil and me.isItemCraftable({name=v.name}) then
- meItemInfo = {}
- meItemInfo.name = v.name
- meItemInfo.amount = 0
- meItemInfo.isCraftable = true
- end
- --Check if the item requested is not nil or air
- if meItemInfo == nil and not me.isItemCraftable({name=v.name}) then
- v.filled = false
- v.status = "No Recipe"
- --debugText(v.name .. " " .. tostring(meItemInfo))
- elseif v.name == "minecraft:air" then
- v.filled = false
- v.status = "Bad Item Name"
- else
- --Check if there is currently enough.
- if meItemInfo.amount > 0 and meItemInfo.amount >= v.count then
- --get direction to push the items use default if not micromanaging
- pushDirection = defaultSide
- pStatus, out = nil
- if microManage then
- pushDirection = getPushDirection(v.target, defaultSide)
- --debugText("Pushed to " .. pushDirection .. " for " .. v.target)
- pStatus, out = pcall(me.exportItemToPeripheral,{name=v.name, count=v.count},pushDirection)
- else
- pStatus, out = pcall(me.exportItemToPeripheral,{name=v.name, count=v.count},defaultSide)
- end
- --move the items and save the request as filled if there is
- if pStatus then
- --debugText("Pushed " .. v.count .. " " .. v.name .. " to " .. pushDirection .. " for " .. v.target)
- v.status = "Filled"
- v.filled = true
- else
- v.status = "Offline Error"
- debugText(out)
- end
- elseif v.crafting then
- v.status = "ME Crafting"
- else
- --check for available crafting cpus
- if me.isItemCraftable({name=v.name}) then
- if cpuCount > 0 then
- --Check if its crafting already
- if v.crafting == false then
- v.craftCount = v.count - meItemInfo.amount
- me.craftItem({name=v.name, count=v.craftCount})
- os.sleep(.05)
- successCraft = me.isItemCrafting({name=v.name})
- if successCraft then
- v.crafting = true
- v.status = "Requesting"
- cpuCount = cpuCount - 1
- else
- v.status = "Unable to Craft"
- end
- else
- if me.isItemCrafting({name=v.name}) then
- v.status = "ME Crafting"
- else
- if v.status == "Finalizing Craft" then
- if v.counter == 5 then
- if v.retry then
- v.status = "Failed to Craft!"
- v.crafting = false
- else
- v.crafting = false
- v.retry = true
- v.status = "Attempting Re-Crafting"
- end
- else
- v.counter = v.counter + 1
- end
- else
- v.status = "Finalizing Craft"
- v.counter = 1
- end
- end
- end
- else
- v.status = "Waiting On CPU's"
- end
- else
- v.status = "No Recipe"
- end
- end
- end
- end
- table.insert(ardata.neededItems,{count = v.count, name = v.name, displayName = v.displayName, status = v.status})
- requestText = requestText .. v.displayName .. " - " .. v.status .. "\n"
- end
- end
- colonyText, currentJobList, queueText, researchText = colonyInfo.showColonyInfo()
- if not doRequests then
- requestText = "Requests are Disabled\n"
- end
- jobText = "^d\nJob List\n^d\n"
- if showJobInfo then
- for cJob,cAmount in pairs(currentJobList) do
- jobText = jobText .. cJob .. " - " .. cAmount .. "\n"
- end
- else
- jobText = "Job Info is Disabled\n"
- end
- if m then
- for i,mon in pairs(m) do
- outputText = ""
- term.redirect(mon)
- clearScreen()
- d = makeDashes(mon)
- --display the buttons
- if mConfig[i][1] then outputText = outputText .. addDashes(colonyText, d) end
- if mConfig[i][3] then outputText = outputText .. addDashes(queueText, d) end
- if mConfig[i][4] then outputText = outputText .. addDashes(researchText, d) end
- if mConfig[i][5] then outputText = outputText .. addDashes(jobText, d) end
- if mConfig[i][2] then outputText = outputText .. addDashes(requestText, d) end
- print(outputText)
- showButtons(i)
- end
- end
- if ar then
- showAR()
- end
- if chat then
- timerID = os.startTimer(delay)
- while true do
- event, k1, k2, k3 = os.pullEvent()
- if event == "timer" and k1 == timerID then
- break
- elseif event == "request" then
- debugText("Chat Event Trigger")
- command = k1
- job = k2
- player = k3
- onList = hasValue(requesterList,job)
- --debugText(tostring(player))
- if command == "add" then
- if onList ~= true then
- table.insert(requesterList,job)
- message(job .. " was added to the list.", player)
- saveConfig()
- else
- message(job .. " is already on the list.", player)
- end
- elseif command == "rm" then
- if onList == true then
- for k,v in pairs(requesterList) do
- if v == job then
- requesterList[k] = nil
- message(job .. " was removed from the list.", player)
- saveConfig()
- break
- end
- end
- else
- message(job .. " is not on the list.", player)
- end
- elseif command == "list" then
- jobList = ""
- for k,v in pairs(requesterList) do
- jobList = jobList .. v .. ", "
- end
- message("Current List: " .. jobList , player)
- elseif command == "arShowAll" then
- if arShowAllResourceRequests then
- arShowAllResourceRequests = false
- else
- arShowAllResourceRequests = true
- end
- message("Showing All Requests: " .. tostring(arShowAllResourceRequests) , player)
- saveConfig()
- elseif command == "jobs" then
- s = ""
- for k,v in pairs(currentJobList) do
- s = " " .. s .. k .. " - " .. v .. "\n"
- end
- message("Current Employment\n" .. s, player)
- elseif command == "output" then
- newOut = textutils.unserialize(k2)
- foundChestMatch = false
- --check if we already have an entry for this inventory
- for k,v in pairs(chestConfig) do
- --if we do, override it.
- if v[2] == newOut[2] then
- chestConfig[k] = newOut
- foundChestMatch = true
- break
- end
- end
- if foundChestMatch == false then
- table.insert(chestConfig, newOut)
- end
- saveConfig()
- elseif command == "doRequests" then
- if doRequests then
- doRequests = false
- else
- doRequests = true
- end
- saveConfig()
- end
- os.queueEvent("confirm",true)
- end
- end
- else
- os.sleep(delay)
- end
- end
- end
- requesterListFull = {"Baker", "Beekeeper", "Blacksmith", "Builder", "Carpenter", "Chicken Farmer", "Composter", "Concrete Mixer", "Cook", "Assistant Cook", "Courier", "Cowhand", "Crusher", "Dyer", "Enchanter", "Farmer", "Fisher", "Fletcher", "Flourist", "Forester", "Glassblower", "Knight", "Archer", "Knight in Training", "Library Student", "Mechanic", "Miner", "Planter", "Pupil", "Rabbit Herder", "Shepherd", "Sifter", "Smelter", "Stonemason", "Stone Smelter", "Swineherd", "Teacher", "Undertaker", "Researcher"}
- color = 0xBBBBBB
- notifyColor = 0xff2222
- headerColor = 0x22ff22
- warnColor = 0xF6FF4F
- compass = {"E", "SE", "S", "SW","W", "NW", "N", "NE"}
- me = peripheral.find("meBridge")
- m = {peripheral.find("monitor")}
- ar = peripheral.find("arController")
- chat = peripheral.find("chatBox")
- colony = peripheral.find("colonyIntegrator")
- playerDetector = peripheral.find("playerDetector")
- requesterList = {}
- config = {}
- if ar then
- ar.setRelativeMode(true, 1600, 900)
- ar.clear()
- end
- passedChecks = true
- if me == nil then
- print("Failed ME")
- passedChecks = false
- end
- if colony == nil then
- print("Colony Peripheral not attached")
- passedChecks = false
- end
- if not colony.isInColony() then
- print("Peripheral is not in a Colony")
- passedChecks = false
- end
- colonyInfo = require("colonyInfo")
- if colonyInfo == nil then
- print("Failed Colony Check")
- passedChecks = false
- end
- mConfig = {}
- mData = {}
- init()
- --setup monitor scaling
- _tm = {}
- _mNames = {}
- for i=1, #m do
- tx, ty = m[i].getSize()
- if tx <=18 or ty <= 12 then
- m[i].setTextScale(.5)
- end
- n = peripheral.getName(m[i])
- fMatch = false
- for k,v in pairs(_mNames) do
- if v == n then
- fMatch = true
- break
- end
- end
- if fMatch == false then
- table.insert(_tm, m[i])
- table.insert(_mNames, n)
- end
- end
- m = _tm
- if #m >= 1 then
- termInstance = term.redirect(m[1])
- end
- if fs.exists("managerConfig.lua") then
- defaultRequester = {"Builder","Miner", "Library Student", "Request System", "Teacher"}
- file = fs.open("managerConfig.lua", "r")
- config = textutils.unserialize(file.readAll())
- file.close()
- requesterList = config.requesterList
- monitorColonyInfo = config.colonyInfo
- arShowAllResourceRequests = config.arShowAllResourceRequests
- showBuilderResourceInfo = config.builderResourceInfo
- delay = config.delay
- doRequests = config.doRequests
- microManage = config.microManage
- chestConfig = config.chestConfig
- defaultSide = config.defaultSide
- showJobInfo = config.showJobInfo
- checkConfigValues()
- else
- requesterList = {"Builder","Miner", "Library Student", "Request System", "Teacher"}
- monitorColonyInfo = true
- arShowAllResourceRequests = true
- showBuilderResourceInfo = false
- delay = 1
- doRequests = true
- microManage = false
- chestConfig = {
- {{x=0,y=0,z=0}, "minecraft:chest_1"},
- {{x=0,y=0,z=0}, "minecraft:chest_2"},
- {{x=0,y=0,z=0}, "minecraft:chest_3"},
- {{x=0,y=0,z=0}, "minecraft:chest_4"},
- }
- defaultSide = "minecraft:chest_0"
- showJobInfo = true
- end
- saveConfig()
- debugText("Colony Manager is now running\nArgs:")
- debugText("monitorColonyInfo - " .. tostring(monitorColonyInfo))
- debugText("arShowAllResourceRequests - " .. tostring(arShowAllResourceRequests))
- debugText("showBuilderResourceInfo - " .. tostring(showBuilderResourceInfo))
- debugText("doRequests - " .. tostring(doRequests))
- debugText("microManage - " .. tostring(microManage))
- debugText("-------------\nLog\n-------------")
- savedRequests = {}
- if chat then
- multishell.launch({},"chatListener.lua")
- end
- showRequestInfo = true
- --bootCycle()
- clearScreen()
- if passedChecks then
- parallel.waitForAny(main,getButtonClick)
- end
Advertisement
Add Comment
Please, Sign In to add comment