Simutrans-Squirrel-API
Public Member Functions | Static Public Member Functions | List of all members

Public Member Functions

 command_x (tool_ids id)
 
integer get_flags ()
 
void set_flags (integer flags)
 
string work (player_x pl, coord3d pos)
 
string work (player_x pl, coord3d pos, string param)
 
string work (player_x pl, coord3d start, coord3d end, string param)
 

Static Public Member Functions

static string build_bridge (player_x pl, coord3d start, coord3d end, bridge_desc_x bridge)
 
static string build_bridge_at (player_x pl, coord3d start, bridge_desc_x bridge)
 
static string build_depot (player_x pl, coord3d pos, building_desc_x depot)
 
static string build_road (player_x pl, coord3d start, coord3d end, way_desc_x way, bool straight, bool keep_city_roads)
 
static string build_sign_at (player_x pl, coord3d pos, sign_desc_x sign)
 
static string build_station (player_x pl, coord3d pos, building_desc_x station, dir rotaton)
 
static string build_way (player_x pl, coord3d start, coord3d end, way_desc_x way, bool straight)
 
static string build_wayobj (player_x pl, coord3d start, coord3d end, wayobj_desc_x wayobj)
 
static string can_set_slope (player_x pl, coord3d pos, slope slope)
 
static string change_climate_at (player_x pl, coord3d pos, integer climate)
 
static string restore_slope (player_x pl, coord3d pos)
 
static string set_slope (player_x pl, coord3d pos, slope slope)
 
static integer slope_get_price (slope)
 

Detailed Description

Proof-of-concept to make tools available to scripts.

The default_param is not checked. Use at own risk.

Definition at line 8 of file api_command.cc.

Constructor & Destructor Documentation

◆ command_x()

command_x::command_x ( tool_ids  id)

Constructor to obtain a tool.

Parameters
idid of the tool

Member Function Documentation

◆ build_bridge()

static string command_x::build_bridge ( player_x  pl,
coord3d  start,
coord3d  end,
bridge_desc_x  bridge 
)
static

Build a bridge. Similar to drag-and-build of bridges in-game.

Parameters
plplayer to pay for the work
startcoordinate, where bridge begins
endcoordinate, where bridge ends
bridgetype of bridge to be built

◆ build_bridge_at()

static string command_x::build_bridge_at ( player_x  pl,
coord3d  start,
bridge_desc_x  bridge 
)
static

Build a bridge. Similar to one click with mouse on suitable start tile: program will figure out bridge span itself.

Parameters
plplayer to pay for the work
startcoordinate, where bridge begins, the end point will be automatically determined
bridgetype of bridge to be built

◆ build_depot()

static string command_x::build_depot ( player_x  pl,
coord3d  pos,
building_desc_x  depot 
)
static

Build a depot.

Parameters
plplayer to pay for the work
posposition to place the depot
depottype of depot to be built

◆ build_road()

static string command_x::build_road ( player_x  pl,
coord3d  start,
coord3d  end,
way_desc_x  way,
bool  straight,
bool  keep_city_roads 
)
static

Build a road.

Parameters
plplayer to pay for the work
startcoordinate, where work begins
endcoordinate, where work ends
waytype of way to be built
straightforce building of straight ways, similar as building way with control key pressed
keep_city_roadsif true city roads will not be replaced

◆ build_sign_at()

static string command_x::build_sign_at ( player_x  pl,
coord3d  pos,
sign_desc_x  sign 
)
static

Build signal / road-sign. If such a sign already exists then change its direction.

Parameters
plplayer to pay for the work
posposition of tile
signtype of road-sign or signal to be built

◆ build_station()

static string command_x::build_station ( player_x  pl,
coord3d  pos,
building_desc_x  station,
dir  rotaton 
)
static

Build a station or station extension building.

Parameters
plplayer to pay for the work
posposition to place the depot
stationtype of station to be built
rotaton(optional parameter) rotation of building (only used for flat docks, put direction from land to water here)

◆ build_way()

static string command_x::build_way ( player_x  pl,
coord3d  start,
coord3d  end,
way_desc_x  way,
bool  straight 
)
static

Build a way.

Parameters
plplayer to pay for the work
startcoordinate, where work begins
endcoordinate, where work ends
waytype of way to be built
straightforce building of straight ways, similar as building way with control key pressed

◆ build_wayobj()

static string command_x::build_wayobj ( player_x  pl,
coord3d  start,
coord3d  end,
wayobj_desc_x  wayobj 
)
static

Build way-object.

Parameters
plplayer to pay for the work
startcoordinate, where work begins
endcoordinate, where work ends
wayobjtype of wayobj to be built

◆ can_set_slope()

static string command_x::can_set_slope ( player_x  pl,
coord3d  pos,
slope  slope 
)
static

Checks whether player pl can do this terraforming.

Parameters
plplayer
posposition
slopenew slope, can also be one of slope::all_up_slope or slope::all_down_slope
Returns
null (if allowed) or an error message otherwise

◆ change_climate_at()

static string command_x::change_climate_at ( player_x  pl,
coord3d  pos,
integer  climate 
)
static

Change climate of tile

Parameters
plplayer to pay for the work
poscoordinate of tile
climatenew climate, possible values see climates

◆ get_flags()

integer command_x::get_flags ( )
Returns
flags set for this tool

◆ restore_slope()

static string command_x::restore_slope ( player_x  pl,
coord3d  pos 
)
static

Restore natural slope of one tile.

Parameters
plplayer to pay for the work
posposition of tile

◆ set_flags()

void command_x::set_flags ( integer  flags)

Sets flags for this tool. Simulates pressing shift or ctrl while clicking with mouse.

Parameters
flagsbitmap, 1 = shift pressed, 2 = ctrl pressed

◆ set_slope()

static string command_x::set_slope ( player_x  pl,
coord3d  pos,
slope  slope 
)
static

Modify the slope of one tile.

Parameters
plplayer to pay for the work
posposition of tile
slopenew slope, can also be one of slope::all_up_slope or slope::all_down_slope.

◆ slope_get_price()

static integer command_x::slope_get_price ( slope  )
static

Costs of using set_slope.

Returns
cost

◆ work() [1/3]

string command_x::work ( player_x  pl,
coord3d  pos 
)

Does the dirty work.

Note
In network games script will be suspended until the command is executed.
Parameters
plplayer to pay for the work
poscoordinate, where something should happen
Returns
null upon success, an error string otherwise

◆ work() [2/3]

string command_x::work ( player_x  pl,
coord3d  pos,
string  param 
)

Does the dirty work.

Note
In network games script will be suspended until the command is executed.
Parameters
plplayer to pay for the work
poscoordinate, where something should happen
parammagic parameter string
Returns
null upon success, an error string otherwise

◆ work() [3/3]

string command_x::work ( player_x  pl,
coord3d  start,
coord3d  end,
string  param 
)

Does the dirty work. Needs two positions for start and end of the work, for e.g., road building.

Note
In network games script will be suspended until the command is executed.
Parameters
plplayer to pay for the work
startcoordinate, where work begins
endcoordinate, where work ends
parammagic parameter string
Returns
null upon success, an error string otherwise

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