News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

r11892 (Sqirrel Script) - bridge build

Started by Andarix, Yesterday at 09:36:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

Quote from: Andarix on March 09, 2026, 03:50:52 PMI consider all this code unnecessary. It's perfectly sufficient to simply align the two bridge ends with the click positions.

I believe the current behavior is a bug. When I drag the bridge with the mouse, the coordinate doesn't jump to the mouse pointer (field 3) but back to field 1 (the river) one level higher.

bridge_drag.png

Quote from: Andarix on March 08, 2026, 06:07:35 PMThis seems suspicious to me.

If I click on the level field as a second click, then position 104,158,-1 is displayed, which is correct.

However, if I click on the slope field 103,158,-1, then position 105,158,0 is displayed. This is the field with the river one level higher. And that doesn't match the clicked field.



prissi

A bug in simutrans? The coordinates for the mouse pointer should be the same as the ones in the lower right corner as these are the only ones the code uses. (When dragging a bridge there is a temporary bridge ground existing though.)

Andarix

If I move the mouse from the other side, the field above the river is returned for the slope field.


is_work_allowed_here()

The function description includes a note. It's possible that this behavior is what's meant by that note.
Quote...
Attention
Does not work with waybuilding and all tools that need path-finding, use the functions provided in rules in this case.
...

It's possible that the function `is_valid_pos()` can be used. However, I don't yet know how to use it.

prissi

During pathfinding, is_work_allowd_here() is called for all tiles of the path. So of course also for the bottom of the river and all tiles in between. (And for way building even more tiles.)

Excatly for this reason there is forbid_way_tool_rect()/allow_way_tool_rect() ...

Andarix

#4
Quote from: prissi on Today at 11:45:47 AM...

Excatly for this reason there is forbid_way_tool_rect()/allow_way_tool_rect() ...

The only question is how that's supposed to work.

I tested it with various combinations.

Either it's not built at all, or the short bridge is built as well.

[EDIT]

I've found a solution. The code still needs improvement.
https://github.com/simutrans/tutorial_multipak/commit/458a8fd1ed5ac85069df6cb8fcee51a90f9d962e