OpenTTD
|
Runtime information about a game script like a pointer to the squirrel vm and the current state. More...
#include <game_instance.hpp>
Public Member Functions | |
void | Initialize (class GameInfo *info) |
Initialize the script and prepare it for its first run. | |
int | GetSetting (const char *name) |
Get the value of a setting of the current instance. | |
ScriptInfo * | FindLibrary (const char *library, int version) |
Find a library. | |
![]() | |
ScriptInstance (const char *APIName) | |
Create a new script. | |
void | Initialize (const char *main_script, const char *instance_name, CompanyID company) |
Initialize the script and prepare it for its first run. | |
void | Continue () |
A script in multiplayer waits for the server to handle his DoCommand. | |
void | GameLoop () |
Run the GameLoop of a script. | |
void | CollectGarbage () const |
Let the VM collect any garbage. | |
class ScriptStorage * | GetStorage () |
Get the storage of this script. | |
void * | GetLogPointer () |
Get the log pointer of this script. | |
class ScriptController * | GetController () |
Get the controller attached to the instance. | |
bool | IsDead () const |
Return the "this script died" value. | |
void | Save () |
Call the script Save function and save all data in the savegame. | |
void | Load (int version) |
Load data from a savegame and store it on the stack. | |
void | Pause () |
Suspends the script for the current tick and then pause the execution of script. | |
bool | IsPaused () |
Checks if the script is paused. | |
void | Unpause () |
Resume execution of the script. | |
SQInteger | GetOpsTillSuspend () |
Get the number of operations the script can execute before being suspended. | |
void | DoCommandCallback (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
DoCommand callback function for all commands executed by scripts. | |
void | InsertEvent (class ScriptEvent *event) |
Insert an event for this script. | |
bool | IsSleeping () |
Check if the instance is sleeping, which either happened because the script executed a DoCommand, executed this.Sleep() or it has been paused. |
Private Member Functions | |
void | RegisterAPI () |
void | Died () |
CommandCallback * | GetDoCommandCallback () |
void | LoadDummyScript () |
Additional Inherited Members | |
![]() | |
static void | DoCommandReturn (ScriptInstance *instance) |
Return a true/false reply for a DoCommand. | |
static void | DoCommandReturnVehicleID (ScriptInstance *instance) |
Return a VehicleID reply for a DoCommand. | |
static void | DoCommandReturnSignID (ScriptInstance *instance) |
Return a SignID reply for a DoCommand. | |
static void | DoCommandReturnGroupID (ScriptInstance *instance) |
Return a GroupID reply for a DoCommand. | |
static void | DoCommandReturnGoalID (ScriptInstance *instance) |
Return a GoalID reply for a DoCommand. | |
static void | DoCommandReturnStoryPageID (ScriptInstance *instance) |
Return a StoryPageID reply for a DoCommand. | |
static void | DoCommandReturnStoryPageElementID (ScriptInstance *instance) |
Return a StoryPageElementID reply for a DoCommand. | |
static void | SaveEmpty () |
Don't save any data in the savegame. | |
static void | LoadEmpty () |
Load and discard data from a savegame. | |
![]() | |
virtual void | RegisterAPI () |
Register all API functions to the VM. | |
bool | LoadCompatibilityScripts (const char *api_version, Subdirectory dir) |
Load squirrel scripts to emulate an older API. | |
virtual void | Died () |
Tell the script it died. | |
virtual CommandCallback * | GetDoCommandCallback ()=0 |
Get the callback handling DoCommands in case of networking. | |
virtual void | LoadDummyScript ()=0 |
Load the dummy script. | |
![]() | |
class Squirrel * | engine |
A wrapper around the squirrel vm. | |
const char * | versionAPI |
Current API used by this script. |
Runtime information about a game script like a pointer to the squirrel vm and the current state.
Definition at line 18 of file game_instance.hpp.
|
virtual |
Find a library.
library | The library name to find. |
version | The version the library should have. |
Implements ScriptInstance.
Definition at line 225 of file game_instance.cpp.
|
virtual |
Get the value of a setting of the current instance.
name | The name of the setting. |
Implements ScriptInstance.
Definition at line 220 of file game_instance.cpp.
References GameConfig::GetConfig(), and ScriptConfig::GetSetting().
void GameInstance::Initialize | ( | class GameInfo * | info | ) |
Initialize the script and prepare it for its first run.
info | The GameInfo to start. |
Definition at line 95 of file game_instance.cpp.
References ScriptInstance::engine, GameInfo::GetAPIVersion(), ScriptInfo::GetInstanceName(), ScriptInfo::GetMainScript(), OWNER_DEITY, and ScriptInstance::versionAPI.
Referenced by Game::StartNew().