Posted 12 July 2016 - 11:35 AM
Ok, first off, im a n00b at this, but for a long time ive wanted to have a screen to monitor my induction Matrix from Mekanism. I couldnt find any scripts that worked so I figgured id write my own. I found a youtube guide, followed it, and then added a few new things based on what I learned.
This is what I want my script to do:
1: Show % of power stored / max power storable.
2: Show total power stored
3: Show power input / max input
4: show power output /max output
I was able to get this to work but then I noticed that CC think mekanism on my server use J instead of RF so it converted it, making all values 2,5X higher then they were supposed to, so I added new parameters for converting this, and while I was at it, divided by 1000 to show Krf instead of RF. Now for the Stored power, this works fine, but on the input/output lines I get the error in the title. The code is the same so I cant figgure this out, please help =(
Also, is there a way to have a comma set into the values? so instead of showing 230083 it shows 230,083? And if so, any ideas how to incorporate this into my code?
Thanks in advance for the assistance.
Also, heres the pastebin: http://pastebin.com/2Y595f4r
This is what I want my script to do:
1: Show % of power stored / max power storable.
2: Show total power stored
3: Show power input / max input
4: show power output /max output
I was able to get this to work but then I noticed that CC think mekanism on my server use J instead of RF so it converted it, making all values 2,5X higher then they were supposed to, so I added new parameters for converting this, and while I was at it, divided by 1000 to show Krf instead of RF. Now for the Stored power, this works fine, but on the input/output lines I get the error in the title. The code is the same so I cant figgure this out, please help =(
power = peripheral.wrap("Induction Matrix_4")
mon = peripheral.wrap("monitor_8")
local maxPower = 0
local curPower = 0
local perPower = 0
local outPower = 0
local inpPower = 0
local capPower = 0
monX,monY = mon.getSize()
function checkPower()
maxPower = power.getMaxEnergy()
curPower = power.getEnergy()
perPower = math.floor(((curPower/maxPower)*100)+0.5)
currentPower = math.floor(((curPower/2.5)/1000000)+0.5)
outPower = power.getOutput()
inpPower = power.getInput()
capPower = power.getTransferCap()
outputPower = math.floor(((outPower/2.5)/1000)+0.5)
inputPower = math.floor(((inpPower/2.5)/1000)+0.5)
cappePower = math.floor(((capPower/2.5)/1000)+0.5)
end
function writeMon()
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setCursorPos(1,1)
-- mon.write("Power")
title = " Power:" .. perPower .. "% Full "
centerT(title, 1, colors.lightGray, colors.blue)
title = " Stored Power:" .. currentPower .."Mrf "
centerT(title, 3, colors.lightGray, colors.blue)
title = " Input:" .. inputPower .. "/" .. cappedPower .. "Krf"
centerT(title, 5, colors.lightGray, colors.blue)
title = " Output:" .. outputPower .. "/" .. cappedPower .. "Krf"
centerT(title, 7, colors.lightGray, colors.blue)
end
function centerT(text,line,backColor,txtColor)
mon.setBackgroundColor(backColor)
mon.setTextColor(txtColor)
length = (string.len(text))
dif= math.floor(monX-length)
x = math.floor(dif/2)
mon.setCursorPos(x+1, line)
mon.write(text)
end
function drawBar()
bar = math.floor(((curPower/maxPower)*(monX-2))+0.5)
mon.setCursorPos(2,monY-4)
mon.setBackgroundColor(colors.red)
mon.write(string.rep(" ", monX-2))
end
while true do
checkPower()
writeMon()
drawBar()
print(curPower .. "/" .. maxPower)
sleep(1)
end
Also, is there a way to have a comma set into the values? so instead of showing 230083 it shows 230,083? And if so, any ideas how to incorporate this into my code?
Thanks in advance for the assistance.
Also, heres the pastebin: http://pastebin.com/2Y595f4r