News:

SimuTranslator
Make Simutrans speak your language.

[r10421]unexpected return value of is_allowed_step function

Started by koa_jp, March 06, 2023, 02:26:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

koa_jp

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

Dwachs

Why is this unexpected? A human player can build such a bridge.
Parsley, sage, rosemary, and maggikraut.

koa_jp

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

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.