The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Yona-TYT on November 30, 2024, 07:37:32 PM

Title: [API Script] rules.forbid_tool is broken
Post by: Yona-TYT on November 30, 2024, 07:37:32 PM
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
Title: Re: [API Script] rules.forbid_tool is broken
Post by: Yona-TYT on December 05, 2024, 02:25:47 PM
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])
}
}
Title: Re: [API Script] rules.forbid_tool is broken
Post by: prissi on December 08, 2024, 01:55:19 PM
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.
Title: Re: [API Script] rules.forbid_tool is broken
Post by: Yona-TYT on December 08, 2024, 02:18:28 PM
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.
Title: Re: [API Script] rules.forbid_tool is broken
Post by: prissi on December 08, 2024, 02:19:10 PM
The old script works too in r11454
Title: Re: [API Script] rules.forbid_tool is broken
Post by: Yona-TYT on December 08, 2024, 07:20:53 PM
Quote from: prissi on December 08, 2024, 02:19:10 PMThe old script works too in r11454
This ir working now   ;D