News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

[API script] Get last use tool with waytype ID

Started by Yona-TYT, February 09, 2026, 05:14:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

I made a small patch to get the last used or default way tool, however for some reason it is failing with waytype = 6, (I'm not sure if I caused it).

Usage:
way_desc_x.get_last_used_way(wt_nr)
0001-ADD-get_last_used_way.patch

prissi

In in r11881, slightly modified.

Yona-TYT

#2
Quote from: prissi on Today at 03:03:25 AMIn in r11881, slightly modified.
slightly do you say?, you changed almost everything hahaha.  ;D ,I'm very happy with the result, you did a good refactoring there. 8) 



"get_default_desc" I don't think that's a good name, since this is specific to waytipes, perhaps something like "get_default_way_desc".


/**


 * Returns the last used (default) way descriptor for a given waytype.


 * This is the way that would be selected when pressing the shortcut key (e.g. 's' for roads).


 * @param wt waytype (1=road_wt, 2=track_wt, 3=tram_wt, etc.)


 * @returns way_desc_x object or null if none available


 */


 STATIC register_method(vm, &tool_build_way_t::get_default_desc, "get_default_desc", false, true);
You need to move this to line 673, as the function is currently not accessible with "way_desc_x.get_default_desc".