9 posts
Posted 27 December 2014 - 08:03 PM
I really need help. I'm not that good at Computercraft but I want to do a cool project and it is almost done, I just need one more thing.
My project works with numbers, and I need somthing to format they like that:
Original number - 1890
Formated: 1.5K
Other example
Original number - 3543256
Formated: 3.5M
What I tried gave me a result of like that:
Original number - 1890
Formated: 1.890K
I don't want that because on milions for example it would be 3.543256M and the text size would be the same, witch I don't want…
1080 posts
Location
In the Matrix
Posted 27 December 2014 - 09:39 PM
What code are you using?
9 posts
Posted 28 December 2014 - 12:05 AM
What code are you using?
It was
Spoiler
m = peripheral.wrap("left")
c = peripheral.wrap("right")
m.clear()
m.setCursorPos(4,1)
m.write("Current Energy Stored")
local timer = 0
local fst = 0
while true do
cell = c.getEnergyStored("south")
m.setBackgroundColor(colors.white)
m.clear()
m.setCursorPos(1,1)
m.setTextColor(colors.red)
cell = (cell/1000)
print("Current Energy:" ..cell)
sleep(0.1)
timer = timer+0.1
print(timer)
if timer >5 then
m.setCursorPos(1,2)
m.setTextColor(colors.orange)
m.write("Energy use (5sec): ,..(cell-fst) ")
fst = c.getEnergyStored("south")
timer = 0
end
end
797 posts
Posted 28 December 2014 - 01:22 AM
Take a look at math.floor().
math.floor( 5.3 ) = 5
math.floor( 2.97 ) = 2
If you want it to go to 1 dp do:
math.floor( n * 10 ) / 10
9 posts
Posted 28 December 2014 - 11:01 AM
Take a look at math.floor().
math.floor( 5.3 ) = 5
math.floor( 2.97 ) = 2
If you want it to go to 1 dp do:
math.floor( n * 10 ) / 10
wow! thank you so much this math floor is awesome…
so… now how I remove a post? :P/>
7508 posts
Location
Australia
Posted 28 December 2014 - 12:13 PM
so… now how I remove a post? :P/>
you don't. as a general rule we do not remove or close a topic in Ask a Pro in the event that others can learn from it, or if you have any further questions related to the same code/script.
9 posts
Posted 28 December 2014 - 07:59 PM
so… now how I remove a post? :P/>
you don't. as a general rule we do not remove or close a topic in Ask a Pro in the event that others can learn from it, or if you have any further questions related to the same code/script.
Hey this community is huge isn't it? I asked it and 7 hours or less was awnered from a moderator :D/>
Know what? I just want to wrote in the same code a percentage thing just to be more fancy,
and I tryed everything and I will say: ITS HARD.
Can anybody help me with that?
Edited on 28 December 2014 - 07:00 PM
3057 posts
Location
United States of America
Posted 28 December 2014 - 10:14 PM
I'm not sure what you mean by "percentage thing", are you referring to the percentage left in the cell? If so, percentage is calculated like this:
current / max * 100
Oh, also:
^please use those. (without the spaces)