Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Tue Mar 19, 2019 8:20 pm

All times are UTC




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Dec 20, 2018 5:56 pm 
Offline
Engineer
Engineer

Joined: Mon May 15, 2017 12:48 pm
Posts: 31
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


Top
   
PostPosted: Thu Dec 20, 2018 6:20 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9208
Location: Sol d
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

_________________
Image
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


Top
   
PostPosted: Thu Dec 20, 2018 6:24 pm 
Offline
Engineer
Engineer

Joined: Mon May 15, 2017 12:48 pm
Posts: 31
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


Top
   
PostPosted: Thu Dec 20, 2018 6:28 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9208
Location: Sol d
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


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.

_________________
Image
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


Top
   
PostPosted: Thu Dec 20, 2018 6:32 pm 
Offline
Engineer
Engineer

Joined: Mon May 15, 2017 12:48 pm
Posts: 31
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


Top
   
PostPosted: Thu Dec 20, 2018 6:34 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9208
Location: Sol d
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.

_________________
Image
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.