|
| 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) |
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.
◆ do_work()
Does the work (for tools of two-click type).
- Returns
- null upon success, an error message otherwise.
- Parameters
-
| pl | player instance to use this tool. |
| start | first tile clicked by user. |
| end | second tile clicked by user. |
| keys | state of ctrl/shift keys. |
◆ exit()
Exits the tool. Do cleanup here.
- Returns
- true upon success.
- Parameters
-
| pl | player instance to use this tool. |
◆ init()
Initializes the tool.
- Returns
- true upon success.
- Parameters
-
| pl | player instance to use this tool. |
◆ is_valid_pos()
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
-
| pl | player instance to use this tool. |
| pos | position to test |
| start | first tile clicked by user |
◆ mark_tiles()
Mark tiles for working (for tools of two-click type). Call mark_tile from here.
- Parameters
-
| pl | player instance to use this tool. |
| start | first tile clicked by user. |
| end | second tile clicked by user. |
| keys | state of ctrl/shift keys. |
◆ work()
Does the work (for tools of one-click type).
- Returns
- null upon success, an error message otherwise.
- Parameters
-
| pl | player instance to use this tool. |
| pos | tile clicked by user, here the work should be done. |
| keys | state of ctrl/shift keys. |