Create ghost before blueprint research

Place to get help with not working mods / modding interface.
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Create ghost before blueprint research

Post by gheift »

Hello,

can someone give me a hint how I can create a ghost while blueprint is not yet researched. I tried

Code: Select all

/c pos = game.player.position e = game.player.surface.create_entity{name = "entity-ghost", inner_name = "small-electric-pole", force = game.player.force, position = {x = pos.x + 1, y = pos.y + 1}}
This returns the created ghost, but is not placed on the surface. A surface.find_entities_filtered immediately after creating the ghost does not returns it. Do I miss a parameter?

Thanks,
Gerhard
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Create ghost before blueprint research

Post by DaveMcW »

Ghosts decay instantly until you increase the time to live.

Code: Select all

/c game.player.force.ghost_time_to_live = 60*60*60
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Create ghost before blueprint research

Post by gheift »

Thanks, that's an evil hack:

Code: Select all

local function place_ghost(surface, entity)
    local force = entity.force
    local gttl = force.ghost_time_to_live
    force.ghost_time_to_live = 4294967295
    local result = {surface.create_entity(entity)}
    force.ghost_time_to_live = gttl
    return unpack(result)
end
Post Reply

Return to “Modding help”