Minimum system: OpenTTD 1.3.0
Version 2 changes:
- minor bug fixes
Vesrion 3 changes:
- minor bug fixes
- the log automatically display the game date now
- with DisableGameDateFromLog() you can set to back the original log format.
Vesrion 4 changes:
- I fixed a bug: after bankrupt a company, an other company is removed from monitoring.
Links, dokcumetntations:
Full documentation: http://feca.homedns.org/documentations/ ... index.html
Full example: http://feca.homedns.org/documentations/ ... ample.html
Available on bananas: http://www.openttd.org/en/bananas/gslibrary/
Details:
With this library you can easily create own Cargo Goal type game in 5 steps:
- Create instance:
Code: Select all
this.cargoMonitor = FGCargoMonitor(this, FGCargoMonitor.LOGLEVEL_ALL);
Code: Select all
this.cargoMonitor.Update();
Code: Select all
this.cargoMonitor.SubscribeToMonitor(company_id, cargo_id, goal_id, FGCargoMonitor.REFRESH_IMMEDIATELY, FGCargoMonitor.MONITOR_ALL_PICKUP, null);
Code: Select all
function FGCargoMonitorTest::SendCargoUpdate(company_id, goal_id, transported)
Code: Select all
this.cargoMonitor.UnSubscribeFromMonitor(company_id, goal_id);
You can subscribe to specific transport goals, example:
- How much coal transported from this city?
- How much steel transported from this industry?
- How much passenger picked up (and delivered) from all city?, etc…
Of course you can subscribe more than one monitor type to specific cargo, example:
- How much coal transported from this coal mine and how much coal transported from all coal mine?
You can subscribe to immediately updates or you can choice the monthly, yearly, etc… updates (REFRESH_TYPES)
Many functions are available to query a specific company and cargo, or given goal of company. But you must subscribe before qurey these monitor types. Example funcitons:
Code: Select all
FGCargoMonitor::AmountOfAllPickedupCargo(company_id, cargo_id)
Code: Select all
FGCargoMonitor::AmountOfAllGoal(company_id, goal_id)
The save and load are easily:
Code: Select all
function FGCargoMonitorTeszt::Save() {
return {
cargoMonitor = this.cargoMonitor.SaveData(),
}
}
function FGCargoMonitorTeszt::Load(version, table) {
this.cargoMonitor.LoadFromData(table.cargoMonitor);
}
You can unsubscribe the speceific company with specefic goal:
- FGCargoMonitor::UnSubscribeFromMonitor(company_id, goal_id)
Also you can unsubscribe all monitor of specific company (if the company went bankrupt or merged):
- FGCargoMonitor::UnSubscribeCompanyFromMonitor(company_id)
Or you can stop all monitoring at the end of the game:
- FGCargoMonitor::UnSubscribeAllFromMonitor()
I tested all function, but errors may occur…
Have fun!
