Posted 02 February 2014 - 10:42 PM
So I've got a program that reads my energy cell and either turns on or off redstone signals to turn engines on or off. And I want to 'print' out some info onto a monitor for easier reading right. I've got the code working great when it prints on the computer as seen in the first picture.
The numbers read correctly, however when I send it over to the monitor it comes out as decimals and I can't figure it out?!
Here is my program. Thanks in advance for any help that you can give!
[attachment=1460:2014-02-02_22.42.48.png]
The numbers read correctly, however when I send it over to the monitor it comes out as decimals and I can't figure it out?!
[attachment=1461:2014-02-02_22.42.43.png]
Here is my program. Thanks in advance for any help that you can give!
mon = peripheral.wrap("left")
cell = peripheral.wrap("cofh_thermalexpansion_energycell_0")
local monw, monh = mon.getSize()
pCount = 0
mon.setTextScale(1)
function getES()
eStored = cell.getEnergyStored("top")
eMax = cell.getMaxEnergyStored("top")
eTemp = (eStored/100)
eTempOne = eMax - (eTemp * 10)
end
function writeLineOne()
mon.clear()
mon.setCursorPos(1,1)
storedLength = tostring(eStored)
mon.setCursorPos((monw-(#storedLength + 16))/2,3)
mon.setTextColor(128)
mon.write("Energy Stored: ")
mon.setTextColor(16)
mon.write(eStored)
end
function writeLineTwo()
countLength = tostring(pCount)
mon.setCursorPos((monw-(#countLength + 17))/2,6)
mon.setTextColor(128)
mon.write("Program Cycles: ")
mon.setTextColor(2048)
mon.write(pCount)
end
function writeLineThree()
if (eStored < eTempOne) or (eStored == 0) then
countRed = 2
else
countRed = 3
end
mon.setCursorPos((monw-(countRed + 11))/2,9)
mon.setTextColor(128)
mon.write("Redstone: ")
mon.setTextColor(16384)
getES()
if (eStored < eTempOne) or (eStored == 0) then
mon.write("ON")
else
mon.write("OFF")
end
end
function monitorPrint()
writeLineOne()
writeLineTwo()
writeLineThree()
end
function clearColor()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(1)
end
function checkEngine()
while true do
getES()
pCount = pCount + 1
if (eStored < eTempOne) or (eStored == 0) then
redstone.setOutput("back", true)
monitorPrint()
clearColor()
write("Energy Stored: ")
term.setTextColor(16)
print(eStored)
term.setTextColor(1)
write("Program Cycles: ")
term.setTextColor(2048)
print(pCount)
term.setTextColor(1)
write("Redstone: ")
term.setTextColor(16384)
print("ON")
else
redstone.setOutput("back", false)
monitorPrint()
clearColor()
write("Energy Stored: ")
term.setTextColor(16)
print(eStored)
term.setTextColor(1)
write("Program Cycles: ")
term.setTextColor(2048)
print(pCount)
term.setTextColor(1)
write("Redstone: ")
term.setTextColor(16384)
print("OFF")
end
sleep(3)
end
end
function waitForEsc()
while true do
local e, key = os.pullEvent("key")
if key ~= 45 then
-- It wasn't escape
return true
end
end
end
parallel.waitForAny(function() checkEngine() end,function() waitForEsc() end)