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

Functions

bool init (player_x pl)
bool exit (player_x pl)
string work (player_x pl, coord3d pos, int keys)
string do_work (player_x pl, coord3d start, coord3d end, int keys)
void mark_tiles (player_x pl, coord3d start, coord3d end, int keys)
integer is_valid_pos (player_x pl, coord3d pos, coord3d start)

Detailed Description

The following methods are vital for the functioning of scripted tools. They will be called from simutrans to interact with the script. You should consider implementing them.

Function Documentation

◆ do_work()

string do_work ( player_x pl,
coord3d start,
coord3d end,
int keys )

Does the work (for tools of two-click type).

Returns
null upon success, an error message otherwise.
Parameters
plplayer instance to use this tool.
startfirst tile clicked by user.
endsecond tile clicked by user.
keysstate of ctrl/shift keys.

◆ exit()

bool exit ( player_x pl)

Exits the tool. Do cleanup here.

Returns
true upon success.
Parameters
plplayer instance to use this tool.

◆ init()

bool init ( player_x pl)

Initializes the tool.

Returns
true upon success.
Parameters
plplayer instance to use this tool.

◆ is_valid_pos()

integer is_valid_pos ( player_x pl,
coord3d pos,
coord3d start )

Can the tool start/end on pos? If it is the second click, start is the position of the first click. Possible return values: 0 = no 1 = This tool can work on this tile (with single click) 2 = On this tile can dragging start/end 3 = Both (1 and 2)

Parameters
plplayer instance to use this tool.
posposition to test
startfirst tile clicked by user

◆ mark_tiles()

void mark_tiles ( player_x pl,
coord3d start,
coord3d end,
int keys )

Mark tiles for working (for tools of two-click type). Call mark_tile from here.

Parameters
plplayer instance to use this tool.
startfirst tile clicked by user.
endsecond tile clicked by user.
keysstate of ctrl/shift keys.

◆ work()

string work ( player_x pl,
coord3d pos,
int keys )

Does the work (for tools of one-click type).

Returns
null upon success, an error message otherwise.
Parameters
plplayer instance to use this tool.
postile clicked by user, here the work should be done.
keysstate of ctrl/shift keys.