OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
13 #include "../script/squirrel_class.hpp"
15 #include "../script/script_storage.hpp"
16 #include "../ai/ai_gui.hpp"
24 #include "../script/api/game/game_includes.hpp"
26 #include "../safeguards.h"
29 GameInstance::GameInstance() :
38 SQGSController_Register(this->
engine);
48 SQGS_RegisterAll(this->
engine);
72 if (info !=
nullptr) {
75 if (info->
GetURL() !=
nullptr) {
76 ScriptLog::Info(
"Please report the error to the following URL:");
77 ScriptLog::Info(info->
GetURL());
uint32 TileIndex
The index/ID of a Tile.
class Squirrel * engine
A wrapper around the squirrel vm.
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
const char * GetMainScript() const
Get the filename of the main.nut script.
const char * GetAPIVersion() const
Get the API version this Game is written for.
@ WL_WARNING
Other information.
static class GameInfo * GetInfo()
Get the current GameInfo.
Runtime information about a script like a pointer to the squirrel vm and the current state.
ScriptInfo * FindLibrary(const char *library, int version) override
Find a library.
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
const char * GetURL() const
Get the website for this script.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Common return value for all commands.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
void RegisterGameTranslation(Squirrel *engine)
Register the current translation to the Squirrel engine.
void RegisterAPI() override
Register all API functions to the VM.
@ GAME_DIR
Subdirectory for all game scripts.
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
DoCommand callback function for all commands executed by Game Scripts.
virtual void RegisterAPI()
Register all API functions to the VM.
void Died() override
Tell the script it died.
void Initialize(const char *main_script, const char *instance_name, CompanyID company)
Initialize the script and prepare it for its first run.
const char * GetInstanceName() const
Get the name of the instance of the script to create.
CommandCallback * GetDoCommandCallback() override
Get the callback handling DoCommands in case of networking.
virtual int GetSetting(const char *name) const
Get the value of a setting for this config.
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Window * ShowAIDebugWindow(CompanyID show_company)
Open the AI debug window and select the given company.
All static information from an Game like name, version, etc.
int GetSetting(const char *name) override
Get the value of a setting of the current instance.
virtual void Died()
Tell the script it died.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
void Continue()
A script in multiplayer waits for the server to handle its DoCommand.
bool LoadCompatibilityScripts(const char *api_version, Subdirectory dir)
Load squirrel scripts to emulate an older API.
All static information from an Script like name, version, etc.
const char * versionAPI
Current API used by this script.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static class GameLibrary * FindLibrary(const char *library, int version)
Wrapper function for GameScanner::FindLibrary.