﻿ in-game money....
• April 25, 2024, 03:24:06 PM
• Welcome, Guest

Pages: [1]

AuthorTopic: in-game money....  (Read 4166 times)

0 Members and 1 Guest are viewing this topic.

redfox

• Regular poster
• Karma: 1
• Offline
• Posts: 122
in-game money....
« on: March 11, 2014, 06:59:39 PM »

I have an inventory item for money \$. and the money figure is displayed over the inventory item.

But I want to display a figure such as \$1.50. The Items figure amount won’t accept the .50 and will only display whole numbers.... 1 2 3 4 5 etc.

How could I go about displaying the .50 over the inventory item or should I only use whole numbers?

Thanks
Logged

Mnemonic

• WME developer
• Karma: 41
• Offline
• Gender:
• Posts: 5683
Re: in-game money....
« Reply #1 on: March 12, 2014, 08:42:55 AM »

Don't use the item.Amount, property, use item.AmountString instead. Then you can assign just about any text to the item.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.

redfox

• Regular poster
• Karma: 1
• Offline
• Posts: 122
Re: in-game money....
« Reply #2 on: March 13, 2014, 02:27:25 PM »

Excellent - item.AmountString works well

I am tracking my \$ and Cents as separate globals - so am dividing my Cents by 100 and adding that to the \$.

Code: [Select]
`var MoneyItem = Game.GetItem("money");moneytotal = moneydollar + (moneycents/100);MoneyItem.AmountString = moneytotal;`
However for \$1.50 my maths calculation displays \$1.500000. Is there a way I can keep decimal places to just 2 integers? And single integers if needed, e.g. \$1.99 to \$1.10 (2 integers) \$1.9 to \$1.1 (1 integer).

I couldn't see how to do that with the maths code.

Logged

Mnemonic

• WME developer
• Karma: 41
• Offline
• Gender:
• Posts: 5683
Re: in-game money....
« Reply #3 on: March 13, 2014, 05:59:07 PM »

Since WME doesn't have any built-in functions for formatting decimal numbers, the easiest way would be probably to compose the string yourself, something like this:

Code: WME Script
1. var MoneyItem = Game.GetItem("money");
2.
3. var centsStr = "";
4. if (moneycents < 10) centsStr = "0";
5. centsStr = centsStr + ToString(moneycents);
6.
7. moneytotal = moneydollar + "." + centsStr;
8. MoneyItem.AmountString = moneytotal;
9.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.

redfox

• Regular poster
• Karma: 1
• Offline
• Posts: 122
Re: in-game money....
« Reply #4 on: March 13, 2014, 06:55:12 PM »

Ah, that works well, thank you very much
Logged
Pages: [1]

Page created in 0.044 seconds with 20 queries.