[1.1.69] LuaSurface::can_place_entity always returns false for transport belt ghosts

Place to get help with not working mods / modding interface.
Post Reply
heartosis
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Oct 01, 2022 3:57 am
Contact:

[1.1.69] LuaSurface::can_place_entity always returns false for transport belt ghosts

Post by heartosis »

I have a mod where I'm replaying other players' actions in multiplayer speedruns for practice purposes. I was calling LuaSurface::can_place_entity on a variety of entities to check if they were placeable before building them, and when attempting to check if ghosts of transport belts could be placed, it unexpectedly returned false, even when the tile is empty and the check returns true on the non-ghost version.

Example (on a new map or in the attached save, where the position just to the right of the starting position is empty):

Code: Select all

/c game.print(game.surfaces[1].can_place_entity{direction=0, inner_name="transport-belt", name="entity-ghost", position={x=1.5,y=-0.5}, force="player", build_check_type=defines.build_check_type.script_ghost})
prints false (it seems like it should be true since it's unimpeded)

Code: Select all

/c game.print(game.surfaces[1].can_place_entity{direction=0, name="transport-belt", position={x=1.5, y=-0.5}, force="player", build_check_type=defines.build_check_type.script_ghost})
prints true (as expected) when it's not a ghost.

Code: Select all

/c game.print(game.surfaces[1].can_place_entity{direction=0, inner_name="inserter", name="entity-ghost", position={x=1.5, y=-0.5}, force="player", build_check_type=defines.build_check_type.script_ghost})
prints true (as expected) for other entities I tried.

splitters, underground belts, and the fast/express versions all have the same issue. I'm not sure if I'm doing the right build_check_type, but the behavior is the same for all build_check_types.
Attachments
can_place_bug.zip
(1.44 MiB) Downloaded 32 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.69] LuaSurface::can_place_entity always returns false for transport belt ghosts

Post by Rseding91 »

Thanks for the report however I think you're misunderstanding how build check types are meant to work. When using a build check type you use the entity you want to check (transport-belt) and the check type of script-ghost.

Code: Select all

/c game.print(game.surfaces[1].can_place_entity{direction=defines.direction.north, name="transport-belt", position={x=1.5,y=-0.5}, force="player", build_check_type=defines.build_check_type.script_ghost})
If you want to get ahold of me I'm almost always on Discord.

heartosis
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Oct 01, 2022 3:57 am
Contact:

Re: [1.1.69] LuaSurface::can_place_entity always returns false for transport belt ghosts

Post by heartosis »

Ah, okay, thanks! I'll switch to doing that. Out of curiosity, if ghosts should use a different build_check_type, what is the purpose of the inner_name argument?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.69] LuaSurface::can_place_entity always returns false for transport belt ghosts

Post by Rseding91 »

heartosis wrote:
Sat Oct 01, 2022 6:37 pm
Ah, okay, thanks! I'll switch to doing that. Out of curiosity, if ghosts should use a different build_check_type, what is the purpose of the inner_name argument?
I guess whoever made the function just copied how create_entity worked.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”