Previous Up Next

6  Gotchas / Bugs

6.1  Case sensitivity

Due to a bug that is not so easy to fix in the short term, variables defined in global must be case insensitive. Otherwise, they may collide on savegame loading. This is only for variables defined in your script. There is no need to maintain case insensitivity in regards to variables defined in global by the game itself, such as ’FACTORY’ (you can safely define your own ’factory’ variable) – the only exception to this is ’me’.

6.2  Global objects

You must never put a game object, such as a droid or a structure, on global. You only get a snapshot of their state, the state is not updated, and they are not removed when they die. Trying to store them globally then using them later will fail.

All variables stored on global (in global scope) are stored when the game is saved, and restored when it is loaded. However, this may not work properly for complex objects. Basic arrays and basic types are supported, but it is generally not recommended to put objects on global, even though simple ones may work. Since the game can’t be saved while a function is running, you don’t need to worry about local variables.

Const definitions are not stored in savegames, and are therefore recommended over variables to hold information that does not change.

6.3  Object states

Most object states that are changed from the scripts are not in fact changed, but queued up to be synchronized among clients. This means that you cannot check the state later in the same script invokation and expect it to have changed. This includes such things as giving orders to droids, setting production to structures, and so on. Instead, if for example you want to mark droids that have been ordered to do something, you can mark them by adding a custom property. Note that this property will not be remembered when it goes out of scope.

6.4  Early research

You cannot set research topics for research labs directly from eventStartLevel. Instead, queue up a function call to set it at some later frame.

6.5  Cyborg construction

Cyborg components are inter-linked, and cannot be passed in as lists as you can with ordinary droids, even though they might look that way.

Previous Up Next