OpenTTD GameScript API: GSAccounting Class Reference

OpenTTD GameScript API 15.0-RC4

Public Member Functions
GSAccounting Class Reference

Class that keeps track of the costs, so you can request how much a block of commands did cost in total. More...

`#include <script_accounting.hpp>`

Inheritance diagram for GSAccounting:

## Public Member Functions
| GSAccounting ()
| Creating instance of this class starts counting the costs of commands from zero.
Money | GetCosts ()
| Get the current value of the costs.
void | ResetCosts ()
| Reset the costs to zero.

## Detailed Description

Class that keeps track of the costs, so you can request how much a block of commands did cost in total.

Works in both Execute as in Test mode. Example:

      {
        local costs = GSAccounting();
        BuildRoad(from_here, to_here);
        BuildRoad(from_there, to_there);
        print("Costs for route is: " + costs.GetCosts());
      }

## Constructor & Destructor Documentation

## ◆ GSAccounting()

GSAccounting::GSAccounting | ( |  | ) |

Creating instance of this class starts counting the costs of commands from zero.

Saves the current value of GetCosts so we can return to the old value when the instance gets deleted.

## Member Function Documentation

## ◆ GetCosts()

Money GSAccounting::GetCosts | ( |  | ) |

Get the current value of the costs.

Returns
  The current costs.

Note
  when nesting GSAccounting instances all instances' GetCosts will always return the value of the 'top' instance.

## ◆ ResetCosts()

void GSAccounting::ResetCosts | ( |  | ) |

Reset the costs to zero.

Note
  when nesting GSAccounting instances all instances' ResetCosts will always effect on the 'top' instance.