[0.17.47] Scripted fast_replace of minable=false machine results in weird half-finished state

Bugs that are actually features.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[0.17.47] Scripted fast_replace of minable=false machine results in weird half-finished state

Post by eradicator »

What?
Calling surface.create_entity{fast_replace=true} on an unminable machine creates target entity but fails to remove the original and does not transfer settings or inventory.
(As discussed in this thread.)

Expected?
The fast_replace attempt should fail as the target is unminable. Or succeed if script is supposed to ignore this. But not stop half-way through.

Reproduction
This will spawn the broken state:

Code: Select all

/c

local p = game.player
local pos = {p.position.x + 0, p.position.y - 5}

one = p.surface.create_entity{
  name = 'assembling-machine-1',
  position = pos,
  force = p.force,
  create_build_effect_smoke = false,
  }
  
one.minable = false
one.set_recipe('iron-gear-wheel')
one.insert'iron-plate'

two = p.surface.create_entity{
  name = 'assembling-machine-3',
  position = pos,
  force = p.force,
  fast_replace = true,
  spill = false,
  create_build_effect_smoke = true,
  }
  
game.print('one:'..tostring(one.valid))
game.print('two:'..tostring(two.valid))
You can teleport the original machine to the side to see it better:

Code: Select all

/c
one.teleport(-3,0)
Fun Fact:
The two same-position machines do not suffer from the "flickering" i saw with the overlapping ores.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: [0.17.47] Scripted fast_replace of minable=false machine results in weird half-finished state

Post by Rseding91 »

Thanks for the re port however this isn't a bug. The entity can't be fast-replaced while minable=false and so using create_entity just creates the entity and does not do fast replace logic.

You need to check https://lua-api.factorio.com/latest/Lua ... st_replace if you care about that.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.17.47] Scripted fast_replace of minable=false machine results in weird half-finished state

Post by eradicator »

Hrng. That'll teach me trying to report other peoples bugs... sorry for wasting your time :|.

Btw, why do these not suffer from the same flicker as the resources tiles from the other thread? They certainly are on the same render layer. Coincidence?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Not a bug”