Ghosts created in LUA code are not aligned to the grid
Posted: Thu Mar 26, 2015 2:37 am
I'm trying to make a mod that would automatically find certain entities, mark them for deconstruction and place ghosts in their place. The problem is that every ghost created by game.createentity is somehow not aligned to the grid. This is part of code responsible for the replacement:
I was also trying to do it in console in game:
And this is the result: http://i.imgur.com/s9t6vBW.png
Creating normal entities:
works well - entity is aligned to the grid, why ghosts are not? Am I doing something wrong?
Code: Select all
local player = game.getplayer(event.playerindex)
local pos = player.position
local entities = game.findentitiesfiltered{
area = {{ pos.x - 32, pos.y - 32 }, { pos.x + 32, pos.y + 32 }},
name = "basic-transport-belt"
}
for i = 1,#entities do
local entity = entities[i]
entity.orderdeconstruction(player.force)
game.createentity{
name = "ghost",
innername = "fast-transport-belt",
position = entity.position,
direction = entity.direction,
force = player.force
}
end
Code: Select all
/c game.createentity{ name = "ghost", innername = "fast-transport-belt", position = game.player.position, direction = 0, force = game.player.force }
Creating normal entities:
Code: Select all
/c game.createentity{ name = "fast-transport-belt", position = game.player.position, direction = 0, force = game.player.force }