Data Structures | Static Public Member Functions | Static Protected Member Functions | Static Private Member Functions | Friends

ScriptObject Class Reference

Uper-parent object of all API classes. More...

#include <script_object.hpp>

Inheritance diagram for ScriptObject:
SimpleCountedObject ScriptAccounting ScriptAirport ScriptBase ScriptBaseStation ScriptBridge ScriptCargo ScriptCompany ScriptDate ScriptEngine ScriptError ScriptEvent ScriptEventController ScriptExecMode ScriptGameSettings ScriptGroup ScriptIndustry ScriptIndustryType ScriptInfrastructure ScriptList ScriptLog ScriptMap ScriptMarine ScriptOrder ScriptRail ScriptRoad ScriptSign ScriptSubsidy ScriptTestMode ScriptTile ScriptTown ScriptTunnel ScriptVehicle

Data Structures

class  ActiveInstance
 A class that handles the current active instance. More...

Static Public Member Functions

static void SetLastCommandRes (bool res)
 Store the latest result of a DoCommand per company.
static class ScriptInstanceGetActiveInstance ()
 Get the currently active instance.

Static Protected Member Functions

static bool DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text=NULL, Script_SuspendCallbackProc *callback=NULL)
 Executes a raw DoCommand for the AI.
static void SetDoCommandCosts (Money value)
 Sets the DoCommand costs counter to a value.
static void IncreaseDoCommandCosts (Money value)
 Increase the current value of the DoCommand costs counter.
static Money GetDoCommandCosts ()
 Get the current DoCommand costs counter.
static void SetLastError (ScriptErrorType last_error)
 Set the DoCommand last error.
static ScriptErrorType GetLastError ()
 Get the DoCommand last error.
static void SetRoadType (RoadType road_type)
 Set the road type.
static RoadType GetRoadType ()
 Get the road type.
static void SetRailType (RailType rail_type)
 Set the rail type.
static RailType GetRailType ()
 Get the rail type.
static void SetDoCommandMode (ScriptModeProc *proc, ScriptObject *instance)
 Set the current mode of your AI to this proc.
static ScriptModeProcGetDoCommandMode ()
 Get the current mode your AI is currently under.
static ScriptObjectGetDoCommandModeInstance ()
 Get the instance of the current mode your AI is currently under.
static void SetDoCommandDelay (uint ticks)
 Set the delay of the DoCommand.
static uint GetDoCommandDelay ()
 Get the delay of the DoCommand.
static bool GetLastCommandRes ()
 Get the latest result of a DoCommand.
static VehicleID GetNewVehicleID ()
 Get the latest stored new_vehicle_id.
static SignID GetNewSignID ()
 Get the latest stored new_sign_id.
static TileIndex GetNewTunnelEndtile ()
 Get the latest stored new_tunnel_endtile.
static GroupID GetNewGroupID ()
 Get the latest stored new_group_id.
static void SetAllowDoCommand (bool allow)
 Store a allow_do_command per company.
static bool GetAllowDoCommand ()
 Get the internal value of allow_do_command.
static void SetLastCost (Money last_cost)
 Set the cost of the last command.
static Money GetLastCost ()
 Get the cost of the last command.
static void SetCallbackVariable (int index, int value)
 Set a variable that can be used by callback functions to pass information.
static int GetCallbackVariable (int index)
 Get the variable that is used by callback functions to pass information.
static bool CanSuspend ()
 Can we suspend the AI at this moment?
static void *& GetEventPointer ()
 Get the pointer to store event data in.
static void *& GetLogPointer ()
 Get the pointer to store log message in.

Static Private Member Functions

static void SetNewVehicleID (VehicleID vehicle_id)
 Store a new_vehicle_id per company.
static void SetNewSignID (SignID sign_id)
 Store a new_sign_id per company.
static void SetNewTunnelEndtile (TileIndex tile)
 Store a new_tunnel_endtile per company.
static void SetNewGroupID (GroupID group_id)
 Store a new_group_id per company.

Friends

class ScriptInstance

Detailed Description

Uper-parent object of all API classes.

You should never use this class in your script, as it doesn't publish any public functions. It is used internally to have a common place to handle general things, like internal command processing, and command-validation checks. none

Definition at line 34 of file script_object.hpp.


Member Function Documentation

ScriptInstance * ScriptObject::GetActiveInstance (  )  [static]
bool ScriptObject::GetAllowDoCommand (  )  [static, protected]

Get the internal value of allow_do_command.

This can differ from CanSuspend() if the reason we are not allowed to execute a DoCommand is in squirrel and not the API. In that case use this function to restore the previous value.

Returns:
True iff DoCommands are allowed in the current scope.

Definition at line 197 of file script_object.cpp.

References ScriptStorage::allow_do_command, and GetStorage().

Referenced by ScriptInstance::Save(), and ScriptList::Valuate().

void ScriptObject::SetAllowDoCommand ( bool  allow  )  [static, protected]

Store a allow_do_command per company.

Parameters:
allow The new allow.

Definition at line 192 of file script_object.cpp.

References ScriptStorage::allow_do_command, and GetStorage().

Referenced by ScriptInstance::GameLoop(), ScriptInstance::Initialize(), ScriptInstance::Save(), and ScriptList::Valuate().

void ScriptObject::SetLastCommandRes ( bool  res  )  [static]

Store the latest result of a DoCommand per company.

Parameters:
res The result of the last command.

Definition at line 137 of file script_object.cpp.

References _build_tunnel_endtile, _new_sign_id, GetStorage(), ScriptStorage::last_command_res, SetNewGroupID(), SetNewSignID(), SetNewTunnelEndtile(), and SetNewVehicleID().

Referenced by _DoCommandReturnSetOrderFlags(), DoCommand(), and ScriptInstance::DoCommandCallback().

void ScriptObject::SetNewGroupID ( GroupID  group_id  )  [static, private]

Store a new_group_id per company.

Parameters:
group_id The new GroupID.

Definition at line 182 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_group_id.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewSignID ( SignID  sign_id  )  [static, private]

Store a new_sign_id per company.

Parameters:
sign_id The new SignID.

Definition at line 162 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_sign_id.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewTunnelEndtile ( TileIndex  tile  )  [static, private]

Store a new_tunnel_endtile per company.

Parameters:
tile The new TileIndex.

Definition at line 172 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_tunnel_endtile.

Referenced by SetLastCommandRes().

void ScriptObject::SetNewVehicleID ( VehicleID  vehicle_id  )  [static, private]

Store a new_vehicle_id per company.

Parameters:
vehicle_id The new VehicleID.

Definition at line 152 of file script_object.cpp.

References GetStorage(), and ScriptStorage::new_vehicle_id.

Referenced by SetLastCommandRes().


The documentation for this class was generated from the following files: