This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
pual11's profile picture

monitor poroblems

Started by pual11, 16 May 2015 - 10:24 PM
pual11 #1
Posted 17 May 2015 - 12:24 AM
i have a problem with my monitor displaying the correct number
i have a small program that reads my enderIO capacitor and gets the number and maks some calculations and displays it in my monitor but i get not the correct number but somthing like
http://prntscr.com/761b3v
and i dont know how i can fix it



m = peripheral.wrap("monitor_0")
c = peripheral.wrap("back")
big = peripheral.wrap("BigReactors-Reactor_0")
--numer of capasitors

cap = 7
reactor = false
function energyR()
energystoredF = c.getEnergyStored("unknown")
energystoredT = energystoredF * cap
end
function getACtive()
if big.getActive() == true then
  reactor = true
else
  reactor = false
end
end

function displayenergy()
m.clear()
m.setCursorPos(1, 1)
m.write("energy = ")
m.write(energystoredT,"")
m.write(" RF")
end
function warning()
if energystoredT < 1000000 then
  m.setBackgroundColour(colors.red)
  else
  end
end
function debug()
write("energy = ")
write(energystoredT)
write(" RF")
end
function reactorActive()
if energystoredT < 1000000 then
  big.setActive(true)
  m.setCursorPos(1,2)
  m.write("reactor is on ")
else
  big.setActive(false)
  m.setCursorPos(1,2)
  m.write("reactor is off")
end
end

m.setTextColor(colors.white)
while true do
getACtive() --looks if the reactor is on
energyR()-- calculates the energy
displayenergy()-- shows the energy on the monitor
reactorActive()-- looks if the reactor needs to turn on
sleep(1)
term.clear()
term.setCursorPos(1,1)
m.setCursorPos(1,1)
m.setBackgroundColour(colors.black)
end
Lupus590 #2
Posted 17 May 2015 - 12:41 AM
with ender io, CC can only see one capacitor block, times the number by the number of capacitor block that make the multi block

I.E. if you are using 3 blocks then you will need to read the value and multiply it by 3 to get the true value

this only effects energy stored and energy capacity and i think it is a problem on enderIO's side
Edited on 16 May 2015 - 10:43 PM
pual11 #3
Posted 17 May 2015 - 12:47 AM
with ender io, CC can only see one capacitor block, times the number by the number of capacitor block that make the multi block

I.E. if you are using 3 blocks then you will need to read the value and multiply it by 3 to get the true value

this only effects energy stored and energy capacity and i think it is a problem on enderIO's side

if you look at my code you can see that i fixed that problem
Bomb Bloke #4
Posted 17 May 2015 - 02:20 AM
The number you're seeing, 1.5733564E7, translates to 1.5733564 * 10^7, or 1.5733564 * 10,000,000, or 15,733,564. The notation is supposed to shrink the number down and make it take up less display space, but it's obviously being applied incorrectly here (by the monitor's "write" function, specifically) - it makes it longer!

You can force the correct format by running the number through tostring() before passing it to m.write(). Eg:

m.write(tostring(energystoredT))
pual11 #5
Posted 17 May 2015 - 02:24 AM
The number you're seeing, 1.5733564E7, translates to 1.5733564 * 10^7, or 1.5733564 * 10,000,000, or 15,733,564. The notation is supposed to shrink the number down and make it take up less display space, but it's obviously being applied incorrectly here (by the monitor's "write" function, specifically) - it makes it longer!

You can force the correct format by running the number through tostring() before passing it to m.write(). Eg:

m.write(tostring(energystoredT))


you fixt it thanks