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

(IC2) MFSU power shows up as exponents

Started by Cokedude, 14 July 2016 - 09:15 PM
Cokedude #1
Posted 14 July 2016 - 11:15 PM
Sorry for the iffy explanation, but I currently have an issue with my monitors showing the MFSU values with exponents instead of a whole number, ex(3.8659811E7 instead of the usual 38659811. http://imgur.com/1g9B9jL)

I had it working fine before, but I edited some of my code and I'm not sure what I've done wrong to make it do this. When I enter the commands below, I get the actual value I should be getting without the exponent so I assume it is somewhere in the code that is making it do that:


>lua p = peripheral.wrap("mfsu_0")
>lua p.getEUStored()
38659811

I will paste the whole program I made below, I don't see anything wrong with it but I am also doing this for my first time so I could be missing something. Thanks in advance to the people who help.exit()


m = peripheral.wrap("monitor_0")
p = peripheral.wrap("mfsu_0")
while true do
m.clear()
m.setTextScale(2)
m.setTextColor(colors.red)
m.setCursorPos(1,1)
m.write("MFSU STATUS")
m.setTextColor(colors.yellow)
m.setCursorPos(1,3)
m.write("Max Capacity: ")
m.setTextColor(colors.green)
m.write(p.getEUCapacity())
m.setTextColor(colors.yellow)
m.setCursorPos(1,4)
m.write("Current Capacity: ")
m.setTextColor(colors.green)
m.write("p.getEUStored())
m.setTextColor(colors.yellow)
m.setCursorPos(1,5)
m.write("Current Load: ")
m.setTextColor(colors.green)
m.write(p.getEUOutputPerTick())
sleep(0.5)
end

Also, is there a way to copy the code from the computer to my clipboard? I wrote this whole thing out myself and there might be an easier way that I don't know of.
Bomb Bloke #2
Posted 15 July 2016 - 12:27 AM
I had it working fine before, but I edited some of my code and I'm not sure what I've done wrong to make it do this.

The output format depends on the function you use to present the number. If you manually tostring() it before you write it you should get what you want.

Also, is there a way to copy the code from the computer to my clipboard?

Not directly, but the pastebin script is the usual way of getting code out of an SMP environment. If you're working in SSP (or have direct server access), then you can find your scripts within the "computers" folder of your world save.
Cokedude #3
Posted 15 July 2016 - 12:41 AM
I had it working fine before, but I edited some of my code and I'm not sure what I've done wrong to make it do this.

The output format depends on the function you use to present the number. If you manually tostring() it before you write it you should get what you want.

Also, is there a way to copy the code from the computer to my clipboard?

Not directly, but the pastebin script is the usual way of getting code out of an SMP environment. If you're working in SSP (or have direct server access), then you can find your scripts within the "computers" folder of your world save.
Im sorry but I have no clue what that means, its only my first day learning. Could you maybe give me an example i could go off?
Bomb Bloke #4
Posted 15 July 2016 - 12:46 AM
I'll assume you're referring to tostring()?

m.write( tostring( p.getEUCapacity() ) )
Cokedude #5
Posted 15 July 2016 - 05:20 AM
I'll assume you're referring to tostring()?

m.write( tostring( p.getEUCapacity() ) )

I just tried that and it didn't seem to work, so I just ended up putting it into one line and getting rid of the color change.


m.write("Max Capacity: '..p.getEUCapacity())