News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

squirrel script - bug select tool by key function is_work_allowed_here()

Started by Andarix, January 16, 2026, 03:55:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

Quote from: Andarix on January 12, 2026, 04:06:29 PMThe idea is correct, but the value is wrong.

The `tool_id` is correct. Only the object name is passed differently.

The name is passed via the button.
The value 1 is passed via the key "s".

Screenshot 2026-01-12 165907.png


Docu function
is_work_allowed_here()

The description doesn't seem to be entirely correct either. There, "name" is defined as "coord3d".

I think this is a simutrans bug, not a tutorial bug.

prissi

This is the intended format:
name => object
number => waytype
Only in the later building stages, the object is know, not at the time when the tool is called, since the last waytape is cached with the tool.

Yona-TYT

Quote from: prissi on January 18, 2026, 11:40:35 AMThis is the intended format:
name => object
number => waytype
Only in the later building stages, the object is know, not at the time when the tool is called, since the last waytape is cached with the tool.

To resolve this, I suggest sending the ID of the pressed 'r' key, something like "key_r". This will allow the script to know that the tool is being called from a keyboard shortcut. Then, we need to look in the configuration parameters to see which track/road is assigned to the keyboard shortcut.

Does the pakset handle choosing exactly which road will be called from the keyboard shortcut?.

prissi

Why? You could just check for the waytype if it is a number string. I.e. waytype==2 and para=="2". If this waytype was allowed before, then it surely will be allowed again, wouldn't it?

You coukd even add a rule like this. It will be always watype=123 and param="123" which forbids using this recall tool.

Andarix

The question is, how many people are using that key during the tutorial? Newcomers, for whom the tutorial is intended, probably aren't.

The issue is that the Squirrel API documentation states that the tool name is passed. Which isn't currently the case.

The fact that we can also consider the waytype via script isn't the problem.

The error therefore doesn't affect Simutrans or the script itself, but rather the Script API. And I'd like to wait for Dwachs's opinion on that.

prissi

One cannot pass the desc name here. No never, impossible. It will not happen, so one has to change the API documentation that the waytype there is a special desciptor name withich is the number of the waytype. (Alternatively, any illegal name will catch that too.)

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

Andarix

I just noticed that the key bindings for routes ignore the timeline.

In pak64.german, the 't' key is assigned to the sand track. However, this track is no longer available at the time of the tutorial.

Yona-TYT

Quote from: Andarix on Today at 03:09:48 PMI just noticed that the key bindings for routes ignore the timeline.

In pak64.german, the 't' key is assigned to the sand track. However, this track is no longer available at the time of the tutorial.
It might be a bug in the code that determines whether the track is available (timeline) or not; I was reviewing that very code when creating the patch, I'll try to investigate it.