Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("top")
- mon = peripheral.wrap("back")
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- defCol = {colors.black,colors.white}
- gx,gy = mon.getSize()
- mon.setTextScale(0.5)
- function cmon(mx,my,text,bcol,tcol)
- if bcol == nil then
- bcol = defCol[1]
- end
- if tcol == nil then
- tcol = defCol[2]
- end
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.setCursorPos(mx,my)
- mon.write(text)
- mon.setBackgroundColor(defCol[1])
- mon.setTextColor(defCol[2])
- end
- function cPrint(text,count)
- t = string.format("%" .. count .. "d",text)
- return t
- end
- function cPrintS(text,count)
- t = string.format("%-" .. count .. "s",text)
- return t
- end
- fuel = {}
- water = {}
- steam = {}
- tmp = {}
- gWater = 4
- gFuel = 10
- gSteam = 16
- tankSize = 100
- function tanks(x,y)
- for v = -1,tankSize + 1,1 do
- cmon(x+v,y," ",colors.white)
- cmon(x+v,y+2," ",colors.white)
- end
- cmon(x-1,y+1," ",colors.white)
- cmon(x+tankSize + 1,y+1," ",colors.white)
- end
- function fillTank(amount,capacity,x,y,color)
- percent = (100 / capacity * amount)
- percentS = string.format("%d",percent)
- percentR = tankSize / 100 * percentS
- for v = 0,percentR,1 do
- cmon(x+v,y," ",colors.black)
- end
- for v = 0,percentR,1 do
- cmon(x+v,y," ",color)
- end
- end
- while true do
- s = sen.getTargets()
- tmp = {}
- for v, k in pairs(s) do
- if k.Name == "Iron Tank Wall" then
- tmp = sen.getTargetDetails(v)
- liquid = tmp.Tanks[1]
- if liquid.Name == "Water" then
- water = liquid
- break
- end
- end
- end
- for v, k in pairs(s) do
- if k.Name == "Iron Tank Wall" then
- tmp = sen.getTargetDetails(v)
- liquid = tmp.Tanks[1]
- if liquid.Name == "Animal Gas" then
- fuel = liquid
- break
- end
- end
- end
- for v, k in pairs(s) do
- if k.Name == "Iron Tank Wall" then
- tmp = sen.getTargetDetails(v)
- liquid = tmp.Tanks[1]
- if liquid.Name == "Steam" then
- steam = liquid
- break
- end
- end
- end
- if fuel.Name == nil then
- fuel.Name = "Animal Gas"
- fuel.Amount = 0
- fuel.Capacity = 0
- end
- if steam.Name == nil then
- steam.Name = "Steam"
- steam.Amount = 0
- steam.Capacity = 0
- end
- if water.Name == nil then
- water.Name = "water"
- water.Amount = 0
- water.Capacity = 0
- end
- if fuel.Amount == nil then
- fuel.Amount = 0
- fuel.Capacity = 0
- end
- if water.Amount == nil then
- water.Amount = 0
- water.Capacity = 0
- end
- if steam.Amount == nil then
- steam.Amount = 0
- steam.Capacity = 0
- end
- waterP = 100 / water.Capacity * water.Amount
- fuelP = 100 / fuel.Capacity * fuel.Amount
- steamP = 100 / steam.Capacity * steam.Amount
- cmon( 2,gWater,cPrintS(water.Name,8),nil,colors.white)
- cmon(10,gWater,cPrint(water.Amount,10) .. " | " .. cPrint(water.Capacity,10) .. " | " .. cPrint(waterP,3) .."%")
- cmon(2,gFuel,cPrintS(fuel.Name,8),nil,colors.white)
- cmon(10,gFuel,cPrint(fuel.Amount,10) .. " | " .. cPrint(fuel.Capacity,10) .. " | " .. cPrint(fuelP,3).."%")
- cmon( 2,gSteam,cPrintS(steam.Name,8),nil,colors.white)
- cmon(10,gSteam,cPrint(steam.Amount,10) .. " | " .. cPrint(steam.Capacity,10) .. " | " .. cPrint(steamP,3).."%")
- if waterP >= 50 then
- cmon(2,gWater,cPrintS(water.Name,8),nil,colors.green)
- else
- cmon(2,gWater,cPrintS(water.Name,8),nil,colors.red)
- end
- if fuelP >= 25 then
- cmon(2,gFuel,cPrintS(fuel.Name,8),nil,colors.green)
- else
- cmon(2,gFuel,cPrintS(fuel.Name,8),nil,colors.red)
- end
- if steamP <= 25 then
- cmon(2,gSteam,cPrintS(steam.Name,8),nil,colors.red)
- oCol = rs.getBundledOutput("right")
- col = colors.subtract(colors.white,oCol)
- rs.setBundledOutput("right",col)
- else
- oCol = rs.getBundledOutput("right")
- col = colors.combine(colors.white,oCol)
- rs.setBundledOutput("right",col)
- cmon(2,gSteam,cPrintS(steam.Name,8),nil,colors.green)
- end
- bundled = rs.getBundledInput("right")
- if waterP >= 50 and fuelP >= 25 and steamP >= 25 then
- cmon(2,2,"Engine Activated",nil,colors.green)
- oCol = rs.getBundledOutput("right")
- col = colors.combine(colors.blue,colors.green,oCol)
- rs.setBundledOutput("right",col)
- else
- cmon(2,2,"Engine Deactivated",nil,colors.red)
- oCol = rs.getBundledOutput("right")
- col = colors.subtract(colors.blue,colors.green,oCol)
- rs.setBundledOutput("right",col)
- end
- tanks(4,gWater + 2)
- tanks(4,gFuel + 2 )
- tanks(4,gSteam + 2)
- fillTank(water.Amount,water.Capacity,4,gWater+3,colors.blue)
- fillTank(fuel.Amount,fuel.Capacity,4,gFuel+3,colors.green)
- fillTank(steam.Amount,steam.Capacity,4,gSteam+3,colors.gray)
- sleep(1)
- shell.run("clear")
- end
Advertisement
RAW Paste Data
Copied
Advertisement