Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Config ]]--
- endertank = true
- -- If enabled, you must place it adjacent to the computer
- -- This is due to a wired modem not attaching to it
- local debug_mode = false
- local side = "top"
- -- Location of the wired modem
- --[[ END OF CONFIG ]]--
- --[[ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING! ]]--
- local net = peripheral.wrap(side)
- --[[ Colour Matrix ]]--
- -- Currently contains all liquids from 1.6.4 Direwolf20 pack
- -- Yes this is a giant block of table!
- -- Hex-code colors are vanilla minecraft's colors
- local liquidColors = {
- -- FORMAT: {rawName, color, display name, hex-code}
- [1]={"Water", colors.blue, "Water", 0x2E388D},
- [2]={"Lava", colors.orange, "Lava", 0xDB7D3E},
- [3]={"Milk", colors.white, "Milk", 0xDDDDDD},
- [4]={"Oil", colors.black, "Oil", 0x191616},
- [5]={"Fuel", colors.yellow, "Fuel", 0xB1A627},
- [6]={"Creosote Oil", colors.yellow, "Creosote", 0xB1A627},
- [7]={"Acid", colors.lime, "Acid", 0x41AE38},
- [8]={"Poison", colors.magenta, "Poison", 0xB350BC},
- [9]={"Liquid Nitrogen", colors.lightBlue, "Nitrogen", 0x6B8AC9},
- [10]={"Sap", colors.brown, "Sap", 0x4F321F},
- [11]={"Resin", colors.brown, "Resin", 0x4F321F},
- [12]={"Latex", colors.lightGray, "Latex", 0x9AA1A1},
- [13]={"Turpentine", colors.brown, "Turpentine", 0x4F321F},
- [14]={"Sewage", colors.brown, "Sewage", 0x4F321F},
- [15]={"Sludge", colors.blue, "Sludge", 0x2E388D},
- [16]={"Mob Essence", colors.green, "Mob Essence", 0x35461B},
- [17]={"Biofuel", colors.purple, "Biofuel", 0x7E3DB5},
- [18]={"Meat", colors.pink, "Meat", 0xD08499},
- [19]={"Pink Slime", colors.pink, "Pink Slime", 0xD08499},
- [20]={"Chocolate Milk", colors.brown, "Chocolate Milk", 0x4F321F},
- [21]={"Mushroom Soup", colors.pink, "Mushroom Soup", 0xD08499},
- [22]={"Molten Iron", colors.red, "Molten Iron", 0x963430},
- [23]={"Molten Gold", colors.yellow, "Molten Gold", 0xB1A627},
- [24]={"Molten Copper", colors.brown, "Molten Copper", 0x4F321F},
- [25]={"Molten Tin", colors.white, "Molten Tin", 0xDDDDDD},
- [26]={"Molten Aluminum", colors.pink, "Molten Aluminum", 0xD08499},
- [27]={"Molten Cobalt", colors.blue, "Molten Cobalt", 0x2E388D},
- [28]={"Molten Ardite", colors.brown, "Molten Ardite", 0x4F321F},
- [29]={"Molten Bronze", colors.brown, "Molten Bronze", 0x4F321F},
- [30]={"Molten Aluminum Brass", colors.yellow, "Molten Aluminum Brass", 0xB1A627},
- [31]={"Molten Manyullyn", colors.purple, "Molten Manyullyn", 0x7E3DB5},
- [32]={"Molten Alumite", colors.pink, "Molten Alumite", 0xD08499},
- [33]={"Molten Obsidian", colors.black, "Molten Obsidian", 0x191616},
- [34]={"Molten Steel", colors.gray, "Molten Steel", 0x404040},
- [35]={"Molten Glass", colors.lightBlue, "Molten Glass", 0x6B8AC9},
- [36]={"Seared Stone", colors.gray, "Seared Stone", 0x404040},
- [37]={"Liquified Emerald", colors.lime, "Liquified Emerald", 0x41AE38},
- [38]={"Blood", colors.red, "Blood", 0x963430},
- [39]={"Molten Nickel", colors.yellow, "Molten Nickel", 0xB1A627},
- [40]={"Molten Lead", colors.purple, "Molten Lead", 0x7E3DB5},
- [41]={"Molten Silver", colors.lightBlue, "Molten Silver", 0x6B8AC9},
- [42]={"fluid.platinum.molten", colors.lightBlue, "Molten Shiny", 0x6B8AC9},
- [43]={"Molten Invar", colors.gray, "Molten Invar", 0x404040},
- [44]={"Molten Electrum", colors.yellow, "Molten Electrum", 0xB1A627},
- [45]={"Resonant Ender", colors.cyan, "Resonant Ender", 0x2E6E89},
- [46]={"Liquid Blueslime", colors.lightBlue, "Liquid Slime", 0x6B8AC9},
- [47]={"Liquid XP", colors.lime, "Liquid XP", 0x41AE38},
- [48]={"Destabilized Redstone", colors.red, "Destabilized Redstone", 0x963430},
- [49]={"Energized Glowstone", colors.yellow, "Energized Glowstone", 0xB1A627},
- [50]={"Blazing Pyrotheum", colors.orange, "Blazing Pyrotheum", 0xDB7D3E},
- [51]={"Gelid Cryotheum", colors.lightBlue, "Gelid Cryotheum", 0x6B8AC9},
- [52]={"Liquifacted Coal", colors.black, "Liquifacted Coal", 0x191616},
- [53]={"Spring Water", colors.lightBlue, "Spring Water", 0x6B8AC9},
- [54]={"fluid.liquidEssence", colors.lightBlue, "Liquid Essence", 0x6B8AC9},
- [55]={"Ethanol", colors.orange, "Ethanol", 0xDB7D3E},
- [56]={"Biomass", colors.lime, "Biomass", 0x41AE38},
- [57]={"Black Ink", colors.black, "Ink", 0x191616},
- [58]={"Crushed Ice", colors.lightBlue, "Crushed Ice", 0x6B8AC9},
- [59]={"Glue", colors.white, "Glue", 0xDDDDDD},
- [60]={"Honey", colors.yellow, "Honey", 0xB1A627}
- }
- local foundTanks = {}
- local enderTanks = {}
- --[[ Functions ]]--
- --[[ Tank Monitor API ]]--
- function enderCheck()
- if endertank then
- local sides = rs.getSides()
- for i=1, #sides do
- local currSide = peripheral.getType(sides[i])
- if currSide == "ender_tank" then
- table.insert(enderTanks, sides[i])
- end
- end
- end
- end
- function cs()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function findTerminal()
- cs()
- local sides = rs.getSides()
- for i=1, #sides do
- local currSide = tostring(peripheral.getType(sides[i]))
- if string.find(currSide, "openperipheral_glassesbridge") then
- fbridge = peripheral.wrap(sides[i])
- print("Terminal mode active!")
- print("I found an OpenPeripheral Glasses Bridge.")
- break
- end
- end
- end
- function debugArray()
- local listing = 1
- for tl=1, #liquidColors do
- local cx, cy = term.getCursorPos()
- local mx, my = term.getSize()
- if listing < 10 then
- write(" "..listing..") ")
- elseif listing >= 10 then
- write(listing..") ")
- end
- term.setCursorPos(mx/mx+6, cy)
- write(liquidColors[tl][3])
- term.setCursorPos(mx/mx+30, cy)
- write(liquidColors[tl][4])
- local pos = string.len(listing.."/") + 2
- term.setCursorPos( mx-pos , cy )
- print(listing.."/"..#liquidColors)
- sleep(1)
- local listing = listing + 1
- end
- end
- function findTanks()
- local connectedPers = peripheral.getNames()
- for i=1, #connectedPers do
- if string.find(connectedPers[i], "tank") then
- table.insert(foundTanks, connectedPers[i])
- end
- end
- if debug_mode then
- print("")
- for i=1, #foundTanks do
- print(foundTanks[i])
- sleep(0.1)
- end
- print("")
- end
- end
- function checkTanks()
- if debug_mode then
- -- Checks the array for the liquid in the tank
- -- This is used for debugging
- for a=1, #foundTanks do
- for b=1, #liquidColors do
- local tankDat = net.callRemote(foundTanks[a], "getTankInfo", "unknown")[1]
- if string.lower(tankDat["rawName"]) == string.lower(liquidColors[b][1]) then
- term.setTextColor(liquidColors[b][2])
- print(liquidColors[b][3])
- term.setTextColor(colors.white)
- sleep(0.1)
- end
- end
- end
- enderCheck()
- if endertank then
- for a=1, #enderTanks do
- for b=1, #liquidColors do
- local currEtank = peripheral.wrap(enderTanks[a])
- local eTankDat = currEtank.getTankInfo("unknown")[1]
- if string.lower(eTankDat["rawName"]) == string.lower(liquidColors[b][1]) then
- term.setTextColor(liquidColors[b][2])
- print("Ender: "..liquidColors[b][3])
- term.setTextColor(colors.white)
- sleep(0.1)
- end
- end
- end
- end
- end
- end
- function addTanks()
- for a=1, #foundTanks do
- for b=1, #liquidColors do
- local currTank = net.callRemote(foundTanks[a], "getTankInfo", "unknown")[1]
- if string.lower(currTank["rawName"]) == string.lower(liquidColors[b][1]) then
- if liquidColors[b][5] and liquidColors[b][6] then
- local currCap = liquidColors[b][5]
- local currAm = liquidColors[b][6]
- liquidColors[b][5] = currTank["capacity"] + currCap
- liquidColors[b][6] = currTank["amount"] + currAm
- else
- liquidColors[b][5] = currTank["capacity"]
- liquidColors[b][6] = currTank["amount"]
- end
- end
- end
- end
- for a=1, #enderTanks do
- for b=1, #liquidColors do
- local currEtank = peripheral.wrap(enderTanks[a])
- local eTankDat = currEtank.getTankInfo("unknown")[1]
- if string.lower(eTankDat["rawName"]) == string.lower(liquidColors[b][1]) then
- if liquidColors[b][5] and liquidColors[b][6] then
- local currECap = liquidColors[b][5]
- local currEAm = liquidColors[b][6]
- liquidColors[b][5] = eTankDat["capacity"] + currECap
- liquidColors[b][6] = eTankDat["amount"] + currEAm
- else
- liquidColors[b][5] = eTankDat["capacity"]
- liquidColors[b][6] = eTankDat["amount"]
- end
- end
- end
- end
- if debug_mode then
- print("")
- for a=1, #liquidColors do
- if liquidColors[a][5] and liquidColors[a][6] then
- term.setTextColor(liquidColors[a][2])
- write(liquidColors[a][3]..": ")
- write(formNum(liquidColors[a][6]).." / ")
- print(formNum(liquidColors[a][5]))
- end
- sleep(0.1)
- end
- end
- end
- function formNum(input)
- local input2 = string.gsub(input, "(%d)(%d%d%d)$", "%1,%2", 1)
- while true do
- local input2, found = string.gsub(input2, "(%d)(%d%d%d),", "%1,%2,", 1)
- if found == 0 then
- return input2
- end
- end
- end
- function bar()
- local event, command = os.pullEvent("chat_command")
- for a=1, #liquidColors do
- if string.lower(command) == string.lower(liquidColors[a][3]) then
- fbridge.clear()
- x, y = 2, 2
- local barBack = fbridge.addGradientBox(x, y, 102, 12, 0x666666, 0.5, 0x999999, 0.5, 1)
- local currLiquid = liquidColors[a][3]..": "..liquidColors[a][6].." / "..liquidColors[a][5]
- local barText = fbridge.addText(x, y+14, currLiquid, liquidColors[a][4])
- barBack.setZ(0)
- break
- elseif a == #liquidColors then
- if liqBar then
- fbridge.clear()
- end
- local guiError = fbridge.addText(2, 2, "Invalid Liquid!", 0x963430)
- end
- end
- return command
- end
- function updateBar(command)
- local errorActive = false
- for a=1, #liquidColors do
- if string.lower(command) == string.lower(liquidColors[a][3]) then
- errorActive = false
- break
- else
- errorActive = true
- end
- end
- if not errorActive then
- for a=1, #liquidColors do
- if string.lower(command) == string.lower(liquidColors[a][3]) then
- liqBar = fbridge.addGradientBox(x+1, y+1, 0, 10, 0x000000, 0.5, liquidColors[a][4], 0.7, 1)
- liqBar.setZ(1)
- break
- end
- end
- end
- for a=1, #liquidColors do
- if string.lower(command) == string.lower(liquidColors[a][3]) then
- liquidRatio = liquidColors[a][6] / liquidColors[a][5]
- break
- end
- end
- local liquidWidth = liquidRatio * 100
- if not errorActive then
- liqBar.setWidth(liquidWidth)
- end
- end
- --[[ Main ]]--
- findTerminal()
- findTanks()
- checkTanks()
- addTanks()
- while true do
- local uCommand = bar()
- updateBar(uCommand)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement