OpenTTD Source
20240919-master-gdf0233f4c2
|
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 "../script/script_cmd.h"
17 #include "../script/script_gui.h"
25 #include "../script/api/game/game_includes.hpp"
27 #include "../safeguards.h"
30 GameInstance::GameInstance() :
39 SQGSController_Register(this->
engine);
49 SQGS_RegisterAll(this->
engine);
76 if (info !=
nullptr) {
79 if (!info->
GetURL().empty()) {
80 ScriptLog::Info(
"Please report the error to the following URL:");
81 ScriptLog::Info(info->
GetURL());
Window * ShowScriptDebugWindow(CompanyID show_company, bool new_window)
Open the Script debug window and select the given company.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
const std::string & GetAPIVersion() const
Get the API version this Game is written for.
class Squirrel * engine
A wrapper around the squirrel vm.
static class GameInstance * GetGameInstance()
Get the current GameScript instance.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ 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.
const std::string & GetMainScript() const
Get the filename of the main.nut script.
ScriptInfo * FindLibrary(const std::string &library, int version) override
Find a library.
Common return value for all commands.
const std::string & GetURL() const
Get the website for this script.
void Initialize(class GameInfo *info)
Initialize the script and prepare it for its first run.
void CommandCallbackData(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
Define a callback function for the client, after the command is finished.
std::vector< uint8_t > CommandDataBuffer
Storage buffer for serialized command data.
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.
virtual void RegisterAPI()
Register all API functions to the VM.
void Died() override
Tell the script it died.
std::string versionAPI
Current API used by this script.
SwitchMode _switch_mode
The next mainloop command.
bool LoadCompatibilityScripts(const std::string &api_version, Subdirectory dir)
Load squirrel scripts to emulate an older API.
CommandCallbackData * GetDoCommandCallback() override
Get the callback handling DoCommands in case of networking.
static GameConfig * GetConfig(ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
void Initialize(const std::string &main_script, const std::string &instance_name, CompanyID company)
Initialize the script and prepare it for its first run.
All static information from an Game like name, version, etc.
int GetSetting(const std::string &name) const
Get the value of a setting for this config.
virtual void Died()
Tell the script it died.
void Continue()
A script in multiplayer waits for the server to handle its DoCommand.
int GetSetting(const std::string &name) override
Get the value of a setting of the current instance.
Commands
List of commands.
const std::string & GetInstanceName() const
Get the name of the instance of the script to create.
static class GameLibrary * FindLibrary(const std::string &library, int version)
Wrapper function for GameScanner::FindLibrary.
All static information from an Script like name, version, etc.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
void CcGame(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
DoCommand callback function for all commands executed by Game Scripts.