Simutrans-Squirrel-API
OTRP v63_4
Loading...
Searching...
No Matches
Common pitfalls
Tables, arrays, strings, classes, instances etc are passed by reference
local a = {}
// create an empty table
local b = a
// b refers to the same table as a
a.x <- 1
// b.x is now also 1
b.x <- 2
// a.x is changed to 2
Do not call API-functions in global scope in the script
local start_time =
settings
.
get_start_time
()
// this call is executed BEFORE the savegame is loaded -> undefined
local factory_coalmine = null
// we can create the variable ...
function
start
()
{
factory_coalmine =
factory_x
(40, 78)
// ... but we can initialize it safely only in a function
}
factory_x
Definition
api_factory.cc:36
settings
Definition
api_settings.cc:5
settings::get_start_time
time_x get_start_time()
start
void start()
Generated by
1.15.0