Hi.
I'm playing version 1.8.0.
I'm testing a modification to an existing game script, and I'm noticing that the function "GSCompany.GetBankBalance(...)" is returning 89600 when my company's balance on the income statement is 179,200.
Is this number purposely scaled in half in the main OpenTTD code? I don't see any reference to that in the API documentation.
Thanks,
Steve
GetBankBalance returning halved value?
Moderator: OpenTTD Developers
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: GetBankBalance returning halved value?
It depends on what currency you use to display your bank balance. The GS functions return the internal money value which is not scaled to any currency (which equals GBP)
https://wiki.openttd.org/Currency
https://wiki.openttd.org/Currency
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Engineer
- Posts: 41
- Joined: 15 May 2017 12:48
Re: GetBankBalance returning halved value?
Thanks, I did not know that.
I'm using USD. I noticed that the update balance was also doubling the value that I used.
So what is the proper process for using the currency? If I want to assess a 10% penalty on the current balance, how do I know what the scaling factor is? Do I care, or do I just operate on the internal values?
Thanks,
Steve
I'm using USD. I noticed that the update balance was also doubling the value that I used.
So what is the proper process for using the currency? If I want to assess a 10% penalty on the current balance, how do I know what the scaling factor is? Do I care, or do I just operate on the internal values?
Thanks,
Steve
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: GetBankBalance returning halved value?
A GS doesn't need to worry about currency of clients. 10% are the same 10% - irrespective of what units you use to display it. The conversion of the money to a currency displayed is done by the display routines of OpenTTD, outside any scripts or NewGRFs.srschacher wrote:Thanks, I did not know that.
I'm using USD. I noticed that the update balance was also doubling the value that I used.
So what is the proper process for using the currency? If I want to assess a 10% penalty on the current balance, how do I know what the scaling factor is? Do I care, or do I just operate on the internal values?
Thanks,
Steve
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
-
- Engineer
- Posts: 41
- Joined: 15 May 2017 12:48
Re: GetBankBalance returning halved value?
Thanks.
What was confusing me was displaying the raw data in debug logs to trace the new code. I thought something was wrong, but now I understand what is going on.
Steve
What was confusing me was displaying the raw data in debug logs to trace the new code. I thought something was wrong, but now I understand what is going on.
Steve
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: GetBankBalance returning halved value?
If you want to avoid this confusion there's two things you can do:
a) choose to play with British Pounds as currency
b) create your own currency which has a conversion factor of 1 wrt the internal money.
a) choose to play with British Pounds as currency
b) create your own currency which has a conversion factor of 1 wrt the internal money.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Who is online
Users browsing this forum: No registered users and 3 guests