Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
I need to allow for 8 digits after the decimal point?

edkeyte
Registered User
Quote
2018-03-06 17:11:24

Hi I'm making a bitcoin miner game kind of in a similar style to a block world game, where the player has to rush round collecting bitcoin
Anyway since it's bitcoin I needs to show the player in a HUD how much bitcoin they have collected... that part is fine but it's showing only 6 digits after the decimal point.

Even if the amount is like this:

0.05000000
I would like to show all the 8 digits after the decimal point even if there are just zeros but It only shows up to 6 always.

Also it loads really slow.

Here's my link:
http://edkeyte.com/bitcoinminerr...

🔎︎



ishmaru
Registered User
Quote
2018-03-06 17:53:45

Are you using Javascript? Its really easy to use the Number.prototype.toFixed() to get what you want.
Read more Here:
https://developer.mozilla.org/en...

So when you update the 2D node text in JS you will then do something like this:
YourBitcoinAmount.toFixed(8)

EX Code:
var bitcoinAmount = ccbGetCopperCubeVariable("Bitcoin Variable Goes Here");
var coinCounterNode = ccbGetSceneNodeFromName("Bitcoin Counter Node Name Goes Here");
ccbSetSceneNodeProperty(coinCounterNode, "Text", "Bitcoin:" + bitcoinAmount.toFixed(8))



Also note that it also looks like your text doesn't quite fit into the node (the last zero is missing some pixels) Make sure you give enough space for the counter.


edkeyte
Registered User
Quote
2018-03-07 01:04:49

Thank you so much ishmaru, Actually I'm not using Javascript but I'll try to implement what you say above.

Ver helpful thank you.

I know it looks like the text doesn't fit but that full background is part of the same HUD so it has a lot a space so i'm not sure why it does that.

I'll keep playing with it to try and fix it.

Thanks ishmaru!
Really grateful!


edkeyte
Registered User
Quote
2018-03-07 01:14:04

WOW! You were right! It was easy to do.
When you said to use Javascript I froze and was afraid when you said that hahah but I added it and it worked.
You did all the work to help me and I just copied and pasted and changed the names etc so I was lucky from your help but I'm very pleased!
Thank you again!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact