Simutrans-Squirrel-API OTRP v63_4
Loading...
Searching...
No Matches

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_way (player_x pl, coord3d start, coord3d end, way_desc_x way, bool straight)
static string build_road (player_x pl, coord3d start, coord3d end, way_desc_x way, bool straight, table args)
static string build_depot (player_x pl, coord3d pos, building_desc_x depot)
static string build_station (player_x pl, coord3d pos, building_desc_x station, dir rotaton)
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 set_slope (player_x pl, coord3d pos, slope slope)
static string restore_slope (player_x pl, coord3d pos)
static string can_set_slope (player_x pl, coord3d pos, slope slope)
static integer slope_get_price (slope)
static string build_sign_at (player_x pl, coord3d pos, sign_desc_x sign)
static string set_stop_before_check (player_x pl, coord3d pos, integer val)
static string set_start_signal (player_x pl, coord3d pos, integer val)
static string set_advance_to_end (player_x pl, coord3d pos, integer val)
static string set_guide_signal (player_x pl, coord3d pos, int val)
static string set_choose_signal (player_x pl, coord3d pos, int val)
static string set_skip_default_route (player_x pl, coord3d pos, int val)
static string set_length_based (player_x pl, coord3d pos, int val)
static string set_margin_length (player_x pl, coord3d pos, int val)
static string set_two_ways (player_x pl, coord3d pos, integer val)
static string build_wayobj (player_x pl, coord3d start, coord3d end, wayobj_desc_x wayobj)
static string change_climate_at (player_x pl, coord3d pos, integer climate)
static string grid_lower (player_x pl, coord3d pos)
static string grid_raise (player_x pl, coord3d pos)

Detailed Description

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

The default_param is not checked. Use at own risk.

Definition at line 9 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()

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()

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()

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()

string command_x::build_road ( player_x pl,
coord3d start,
coord3d end,
way_desc_x way,
bool straight,
table args )
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
argstable of arguments (keep_city_roads, overtaking_mode, street_flag, height_offset, vehicle_offset, allow_closed_diagonal (default true))

◆ build_sign_at()

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()

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()

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()

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()

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()

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

◆ grid_lower()

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

Lower grid point

Parameters
plplayer to pay for the work
poscoordinate of tile, grid point in nw corner will be lowered

◆ grid_raise()

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

Raise grid point

Parameters
plplayer to pay for the work
poscoordinate of tile, grid point in nw corner will be lowered

◆ restore_slope()

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_advance_to_end()

string command_x::set_advance_to_end ( player_x pl,
coord3d pos,
integer val )
static

Sets "advance to end" flag on a choose signal.

Parameters
plplayer executing the command
posposition of signal
valnew state of the flag
Returns
null if successful, an error string otherwise

◆ set_choose_signal()

string command_x::set_choose_signal ( player_x pl,
coord3d pos,
int val )
static

Sets "choose signal" flag on a signal.

Parameters
plplayer executing the command
posposition of signal
valnew state of the flag
Returns
null if successful, an error string otherwise

◆ 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_guide_signal()

string command_x::set_guide_signal ( player_x pl,
coord3d pos,
int val )
static

Sets "require parent convoy to enter" (guide signal) flag on a signal.

Parameters
plplayer executing the command
posposition of signal
valnew state of the flag
Returns
null if successful, an error string otherwise

◆ set_length_based()

string command_x::set_length_based ( player_x pl,
coord3d pos,
int val )
static

Sets "length based" flag on a choose signal.

Parameters
plplayer executing the command
posposition of signal
valnew state of the flag
Returns
null if successful, an error string otherwise

◆ set_margin_length()

string command_x::set_margin_length ( player_x pl,
coord3d pos,
int val )
static

Sets "margin length" on a choose signal.

Parameters
plplayer executing the command
posposition of signal
valnew margin length
Returns
null if successful, an error string otherwise

◆ set_skip_default_route()

string command_x::set_skip_default_route ( player_x pl,
coord3d pos,
int val )
static

Sets "skip default route" flag on a choose signal.

Parameters
plplayer executing the command
posposition of signal
valnew state of the flag
Returns
null if successful, an error string otherwise

◆ set_slope()

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.

◆ set_start_signal()

string command_x::set_start_signal ( player_x pl,
coord3d pos,
integer val )
static

Set or clear the "start signal" flag on a rail signal. When set, a convoy in CAN_START or CAN_START_ONE_MONTH state checks whether this signal (the next signal ahead) is clear before departing. If the signal is RED the convoy stays put; if GREEN it departs normally.

Parameters
plplayer who owns the signal
posposition of the signal tile
val1 to enable, 0 to disable
Returns
null on success, an error string otherwise

◆ set_stop_before_check()

string command_x::set_stop_before_check ( player_x pl,
coord3d pos,
integer val )
static

Set or clear the "stop before check" flag on a rail signal. Applicable to simple signals, longblock signals and choose signals.

Parameters
plplayer who owns the signal
posposition of the signal tile
val1 to enable, 0 to disable
Returns
null on success, an error string otherwise

◆ set_two_ways()

string command_x::set_two_ways ( player_x pl,
coord3d pos,
integer val )
static

Set or clear the "allow reverse passage" (two ways) flag of a signal. When set (true), trains coming from the reverse direction are allowed to pass the signal. When cleared (false), the signal strictly blocks trains from the reverse direction.

Parameters
plplayer who owns the signal
posposition of the signal tile
val1 to enable, 0 to disable
Returns
null on success, an error string otherwise

◆ slope_get_price()

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: