Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ComputerCraft/OpenPeripherals Base Monitoring Program for MC 1.6.4
- -- Thanks: Fogger, @EsperNet: #OpenMods, #computercraft @Freenode: #lua
- term.clear()
- -- LOAD APIs -------------------------------------------
- print("Updating and Loading APIs...")
- if fs.exists("marik") then
- shell.run("rm marik")
- end
- shell.run("pastebin get sZ13tEft marik")
- os.unloadAPI("marik")
- os.loadAPI("marik")
- if not fs.exists("config") then
- print("Config does not exist. Use -newcfg")
- else
- os.unloadAPI("config")
- os.loadAPI("config")
- end
- --------------------------------------------------------
- local palette = {["white"] = 1, ["orange"] = 2, ["magenta"] = 4, ["lightBlue"] = 8, ["yellow"] = 16,
- ["lime"] = 32, ["pink"] = 64, ["gray"] = 128, ["lightGray"] = 256, ["cyan"] = 512, ["purple"] = 1024,
- ["blue"] = 2048, ["brown"] = 4096, ["green"] = 8192, ["red"] = 16384, ["black"] = 32768}
- -- MONITORS
- left = config.left
- right = config.right
- aux1 = config.aux1
- -- VARIOUS
- local activeMsg, inactiveMsg, pendingMsg = "USING", "INACT", "PENDN"
- local textSize = 1 -- increments of 0.5
- isGPS = false
- -- MACHINE and PERIPHERAL NAMES --
- -- Use the same # of characters for each so that formatting is aligned
- name_comp = "CMPRESR" -- compressor
- name_furnace = "FURNACE" -- electric furnace
- name_ext = "EXTRCTR" -- extractor
- name_mace = "MACERTR" -- macerator
- name_washer = "ORWASHR" -- ore washer
- name_centrifuge = "THR_CTR" -- thermal centrifuge
- name_former = "MTL_FRM" -- metal former
- name_recycler = "RECYCLR" -- recycler
- name_canning = "CAN_MCN" -- canning machine
- -- OTHER Machine Names
- name_mfsu = "MFSU"
- name_batbox = "BTBX"
- -- COLORS
- local hc = palette.lightBlue -- default heading color
- local tc = palette.white -- default text color
- local color_reading = palette.lime -- power readings for example
- local color_inactive = palette.gray -- inactive reading for machines
- local color_active = palette.red -- active reading for machines
- local color_machines = palette.orange -- machine names
- local color_ores = palette.pink -- ore name color
- -- TEXT POSITIONS
- local pos_PwrReading = 20 -- pos to display power readings
- local pos_Machines = 7 -- pos to display machine heading
- local pos_MachineDisplay = 8 -- pos to start displaying machine activity
- local offsetPos = 2 -- left margin offset for text
- local pos_mStatus = 11 -- machine status
- local pos_Ore = 18 -- machine input item position
- local pos_TankStart = 1 -- RC tank position start
- local GPS_x = 25
- local GPS_y = 58
- local devicePos = 3 -- starting position of EU storage devices
- -- SPECIAL CHARACTERS
- local separator = " | "
- local spacer = " : "
- -------------------------------------------------------------------------
- local waitTime = {9,13}
- local timer = {0,0,0,0,0,0,0,0,0,0,0}
- local supported_Power = {"mfsu","cesu","mfe","batbox"}
- local supported_Machines = {"macerator","furnace","orewashing","thermalcentrifuge", "extractor",
- "compressor", "canning", "recycler", "metalformer"}
- local sleepAmt = 0.2
- local ic2ItemUsed = 7 -- input slot for most ic2 machines
- local ic2ItemCreated = 2 -- output slot for most ic2 machines
- local oreWashItemUsed = 9 -- input slot for orewasher
- local thermCentrItemUsed = 9 -- input slot for thermal centrifuge
- machines = marik.pLoad()
- -- Monitors
- local mon = peripheral.wrap(left)
- local mon2 = peripheral.wrap(right)
- mon.clear()
- mon2.clear()
- mon.setTextScale(textSize)
- mon2.setTextScale(textSize)
- function pFormat(pName)
- -- Renames peripherals for formatting purposes
- if string.find(pName, "compressor") then
- pName = name_comp
- elseif string.find(pName, "electric_furnace") then
- pName = name_furnace
- elseif string.find(pName, "extractor") then
- pName = name_ext
- elseif string.find(pName, "macerator") then
- pName = name_mace
- elseif string.find(pName, "orewashing") then
- pName = name_washer
- elseif string.find(pName, "thermalcentrifuge") then
- pName = name_centrifuge
- elseif string.find(pName, "canning") then
- pName = name_canning
- elseif string.find(pName, "recycler") then
- pName = name_recycler
- elseif string.find(pName, "former") then
- pName = name_former
- elseif string.find(pName, "mfsu") then
- pName = name_mfsu
- elseif string.find(pName, "batbox") then
- pName = name_batbox
- end
- return pName
- end
- function dispAE()
- -- AE TERMINAL (not working yet)
- mon2.setTextColor(tc)
- mon2.setCursorPos(offsetPos,aeCraftCol)
- beingCrafted = aeController.getJobList()
- if beingCrafted.name ~= nil then
- timer[1] = os.clock()
- mon2.clearLine()
- mon2.write("Currently Crafting: " .. beingCrafted.name)
- elseif beingCrafted.name == nil then
- mon2.clearLine()
- mon2.write("Currently Crafting: Nothing")
- else
- mon2.clearLine()
- mon2.write("Currently Crafting: Unknown")
- end
- end
- function dispTanks()
- mon.setCursorPos(offsetPos, 1)
- mon2.setCursorPos(offsetPos,1)
- for i=1, #machines do
- -- RC Tanks --------------------------------------------
- if string.find(machines[i], "rcirontankvalvetile")
- or string.find(machines[i], "rcsteeltankvalvetile") then
- if peripheral.isPresent(machines[i]) then
- periph = peripheral.wrap(machines[i])
- fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID = marik.getTank(periph)
- if fluidName == nil then
- -- does not display empty tanks
- elseif fluidName ~= nil then
- mon2.setTextColor(tc)
- x,y = mon2.getCursorPos()
- mon2.setCursorPos(offsetPos, (y+1))
- mon2.clearLine()
- -- marik.cString(offsetPos,(y+1), tc, right, " ")
- mon2.write("Tank (" .. marik.comma(fluidName) .. ") : " .. marik.comma(fluidAmount) .. " / " .. marik.comma(fluidCapacity) .. " mb (" .. marik.getBuckets(fluidAmount) .. " buckets)")
- end
- end
- end
- end
- end
- function dispPower()
- local storedEU
- local capacity
- local totalStorage = 0
- local totalCapacity = 0
- local s
- local i
- pos_Power = devicePos
- for i=1, #machines do
- -- IC2 Power -------------------------------------------
- for s=1, #supported_Power do
- if string.find(machines[i], supported_Power[s]) then
- periph = peripheral.wrap(machines[i])
- storedEU = periph.getEUStored()
- capacity = periph.getEUCapacity()
- pos_Power = pos_Power + 1 -- everytime we find a power storage unit we display it 1 column lower
- -- modify these later for multiple storage peripherals
- totalStorage = totalStorage + storedEU
- totalCapacity = totalCapacity + capacity
- marik.appendString(left, tc, "EU Current " .. separator, true, offsetPos, 2)
- marik.appendString(left, color_reading, (marik.comma(totalStorage)), false, pos_PwrReading, 2)
- marik.appendString(left, tc, "EU Capacity " .. separator, true, offsetPos, 3)
- marik.appendString(left, color_reading, (marik.comma(totalCapacity)), false, pos_PwrReading, 3)
- -- to do: setup to display multiple power devices (also need to push the machine list down for each one)
- marik.appendString(left, tc, pFormat(machines[i]) .. " EU Stored " .. separator, true, offsetPos, (pos_Power))
- marik.appendString(left, color_reading, (marik.comma(storedEU)), false, pos_PwrReading, (pos_Power))
- end
- end
- end
- end
- function dispIC2()
- machineDispStart = pos_Power + 1 -- start machine display below the power display
- machines = marik.pLoad()
- for i=1, #machines do
- -- IC2 Machines -----------------------------------------
- local m
- for m=1, #supported_Machines do
- -- check if the machine is a supported machine
- if string.find(machines[i], supported_Machines[m]) then
- -- check if the peripheral is connected
- -- if peripheral.isPresent(machines[i]) then
- periph = peripheral.wrap(machines[i])
- -- determine what slot to use for the machines' input
- if string.find(machines[i], "thermalcentrifuge") then itemStackUsed = periph.getStackInSlot(thermCentrItemUsed)
- elseif string.find(machines[i], "orewashing") then itemStackUsed = periph.getStackInSlot(oreWashItemUsed)
- else itemStackUsed = periph.getStackInSlot(ic2ItemUsed)
- end
- -- if there's something in the input slot
- -- bug here.. displays only a few machines now if some are inactive
- if itemStackUsed ~= nil then
- itemName = marik.itemRename(itemStackUsed.name)
- timer[2] = os.clock()
- -- display machine, active message and itemName
- machineDispStart = machineDispStart + 1
- marik.appendString(left, color_ores, itemName, true, pos_Ore, machineDispStart) -- append the itemName
- str = (pFormat(peripheral.getType(machines[i])))
- marik.appendString(left, tc, str, false, offsetPos, machineDispStart) -- append the machine name to the beginning
- marik.appendString(left, color_active, activeMsg, false, pos_mStatus, machineDispStart) -- append ACTIVE
- -- if there is nothing in the input slot
- elseif itemStackUsed == nil then
- if os.clock() - timer[2] > waitTime[1] then
- --display machine and inactive message
- machineDispStart = machineDispStart + 1
- marik.appendString(left, color_inactive, inactiveMsg, true, pos_mStatus, machineDispStart) -- append INACTIVE
- str = (pFormat(peripheral.getType(machines[i])))
- marik.appendString(left, tc, str, false, offsetPos, machineDispStart) -- append the machine name to the beginning
- end
- end
- end
- end
- end
- end
- -- Loop Start
- while true do
- mon.setTextColor(tc)
- if marik.GPSinfo() then
- mon.setCursorPos(GPS_y, GPS_x)
- mon.write("GPS: Online")
- else
- mon.setCursorPos(GPS_y, GPS_x)
- mon.write("GPS: Offline")
- end
- machines = marik.pLoad()
- dispTanks()
- dispPower()
- dispIC2()
- sleep(sleepAmt)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement