News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[API Script] rules.forbid_tool is broken

Started by Yona-TYT, November 30, 2024, 07:37:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

Menu bar icons are no longer filtering with rules

I made a mini test for this, but it's a bit tricky to automate this.

I tried this on r11400 and it passes the tests: test-tool_menu.zip

Yona-TYT

This is not working as expected.:
/* PAK64 MENUS:
SLOPETOOLS 0x8002
RAILTOOLS 0x8003
ROADTOOLS 0x8006
SHIPTOOLS 0x8007
SPECIALTOOLS 0x8009
AIRTOOLS 0x8008
*/
tool_list <- [0x8002,0x8003,0x8006,0x8007,0x8008,0x8009,0x1008]

function forbid_tools_menu()
{
for(local j=0; j<tool_list.len(); j++) {
rules.forbid_tool(player_all, tool_list[j])
}
}

prissi

Since these tools have a default paramter, on could use this one
tool_list <- [0x8002,0x8003,0x8006,0x8007,0x8008,0x8009,0x800A]
parameter_list <- ["SLOPETOOLS","RAILTOOLS","ROADTOOLS","SHIPTOOLS","AIRTOOLS","SPECIALTOOLS","EDITTOOLS"]

...

function forbid_tools_menu()
{
for(local j=0; j<tool_list.len(); j++) {
rules.forbid_way_tool(player_all, tool_list[j], -1, parameter_list[j])
}
}

But that means the empty default parameter does not longer catches all. r11454 should fix this.

Yona-TYT

Quote from: prissi on December 08, 2024, 01:55:19 PMSince these tools have a default paramter, on could use this one
tool_list <- [0x8002,0x8003,0x8006,0x8007,0x8008,0x8009,0x800A]
parameter_list <- ["SLOPETOOLS","RAILTOOLS","ROADTOOLS","SHIPTOOLS","AIRTOOLS","SPECIALTOOLS","EDITTOOLS"]

...

function forbid_tools_menu()
{
for(local j=0; j<tool_list.len(); j++) {
rules.forbid_way_tool(player_all, tool_list[j], -1, parameter_list[j])
}
}

But that means the empty default parameter does not longer catches all. r11454 should fix this.
This is excellent, I will do some tests later, I also need to update the scenarios.

prissi