Page 1 of 1

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

Posted: Tue Jul 02, 2019 6:41 am
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.

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

Posted: Tue Jul 02, 2019 9:39 am
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.

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

Posted: Tue Jul 02, 2019 10:35 am
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?