[1.1.34] Crash when attempting to paste lua-script created blueprint with invalid snap-to-grid configuration

Bugs that we were not able to reproduce, and/or are waiting for more detailed info.
Post Reply
GlassBricks
Inserter
Inserter
Posts: 25
Joined: Fri Jun 11, 2021 5:20 pm
Contact:

[1.1.34] Crash when attempting to paste lua-script created blueprint with invalid snap-to-grid configuration

Post by GlassBricks »

I'm creating a (yet to be released) mod that involves programmatically creating/pasting blueprints.

In the mod, using lua, I created a blueprint (inside a container inside a custom surface to hold the LuaItemStack), set blueprint_position_relative_to_grid, but did not set blueprint_snap_to_grid. When I tried to place this blueprint (from lua), the game (not the mod) crashed.

Setting blueprint_snap_to_grid to {1,1} avoided the crash.

I would expect the blueprint pasting to fail gracefully or provide a reasonable default behavior, instead of crashing the game.
Attachments
factorio-current.log
(13.53 KiB) Downloaded 294 times

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [1.1.34] Crash when attempting to paste lua-script created blueprint with invalid snap-to-grid configuration

Post by posila »

Hello, thanks for the report.
Can you provide the lua code that causes the crash, please?

GlassBricks
Inserter
Inserter
Posts: 25
Joined: Fri Jun 11, 2021 5:20 pm
Contact:

Re: [1.1.34] Crash when attempting to paste lua-script created blueprint with invalid snap-to-grid configuration

Post by GlassBricks »

Here's a portion of the code that produced the crash:

Code: Select all

-- (in a function)
local blueprint = getBpForLayer() -- creates and returns a LuaItemStack in a script inventory, that is a blueprint
local blueprintedEntities = blueprint.create_blueprint({surface = self.surface, force = "player", area = self.area, include_entities = true, include_modules = true, include_trains = true, include_station_names = true, include_fuel = true})
if isEmpty(blueprintedEntities) then
    return blueprint
end
local someEntity = blueprintedEntities[1]
local blueprintEntity = blueprint.get_blueprint_entities()[1]
-- blueprint.blueprint_snap_to_grid = {1, 1} -- Omitting this line results in crash
blueprint.blueprint_position_relative_to_grid = position:subtract(someEntity.position, blueprintEntity.position) -- util function that subtracts x and y
return blueprint

-- (run later)

blueprint.build_blueprint({surface = self.surface, force = "player", position = {0, 0}, skip_fog_of_war = false, force_build = forceBuild})

Post Reply

Return to “Pending”