The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: koa_jp on March 06, 2023, 02:26:49 PM

Title: [r10421]unexpected return value of is_allowed_step function
Post by: koa_jp on March 06, 2023, 02:26:49 PM
Hi.
I notice returned true when both flat but different height tile.

gui.add_message_at(our_player, "test start!", world.get_time())
local as = astar_builder()
as.builder = way_planner_x(our_player)

if(way == null){ return }
as.way = way
as.builder.set_build_types(way)
as.bridger = pontifex(our_player, way)

local from = tile_x(5,5,9)
local to = tile_x(5,6,10)
gui.add_message_at(our_player, ":::"+as.builder.is_allowed_step(from, to), world.get_time())

execute result is following.
simscr03.png
Title: Re: [r10421]unexpected return value of is_allowed_step function
Post by: Dwachs on March 06, 2023, 08:14:18 PM
Why is this unexpected? A human player can build such a bridge.
Title: Re: [r10421]unexpected return value of is_allowed_step function
Post by: koa_jp on March 07, 2023, 01:35:48 PM
Quote from: Dwachs on March 06, 2023, 08:14:18 PMWhy is this unexpected? A human player can build such a bridge.

I didn't know this function considered not only way but also bridge.
It could also be used in script AI.
Thanks.

gui.add_message_at(our_player, "test start!", world.get_time())
local as = astar_builder()
as.builder = way_planner_x(our_player)
if(way == null){ return }
as.way = way
as.builder.set_build_types(way)
as.bridger = pontifex(our_player, way)

local from = tile_x(5,5,9)
local to = tile_x(5,6,10)
gui.add_message_at(our_player, ":::"+as.builder.is_allowed_step(from, to), world.get_time())
local err=command_x.build_bridge(our_player, from, to, as.bridger.bridge)
gui.add_message_at(our_player, ""+err, world.get_time())

simscr04.png
Title: Re: [r10421]unexpected return value of is_allowed_step function
Post by: Dwachs on March 07, 2023, 06:17:55 PM
Oh, I see. Apparently, the method does not check whether the tiles are neighboring. And it also does not check that the flat tiles are at the same height. This needs to be fixed.