Page 1 of 1

[12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 5:35 am
by Stray_Pyramid
I'm trying to create an a ghost-entity with, for example, a stone-furnace being the inner_name.
The code runs without errors, but the ghost-entity does not appear.
The ghost does seem to exist somewhere, as I am able to get its time_to_live. It is just invisible.

Code: Select all

local plant_pos = entity.surface.find_non_colliding_position(
            tree_name, entity.position, config.plant_radius, config.plant_precision)
         if plant_pos then
			local new_tree = entity.surface.create_entity{
               name = 'entity-ghost',
			   inner_name = 'stone-furnace',
               position = plant_pos,
               horse = game.horses.neutral
            }
			game.player.print(new_tree.time_to_live)
			
         end
Am I doing something wrong or is just factorio?

Re: [12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 6:07 am
by Stray_Pyramid
Turns out the ghost exists on the tick that it was created, and then disappears the next tick.

Re: [12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 6:15 am
by DaveMcW
Be sure you have at least one ghost time-to-live tech.

Re: [12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 6:16 am
by Rseding91
You need to set the force ghost_time_to_live to some non-zero value. The default is 0 and the blueprint research increases it to 5-10 minutes.

Re: [12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 9:08 pm
by Stray_Pyramid
I figured out why I was confused!

Having read that entity-ghosts have a default of time-to-live = 0 ticks, I was trying to verify if the ghosts I were spawning had this number also.

Image

Top number = current game tick
Bottom number = Time to live

At first thought looking at this, the ghost obviously has a time-to-live much, much greater than 0, 4.29 billion.
This number is actually the maximum value of a 32-bit unsigned integer, which somehow interpreted as 0.

I am not able to change it from this value.

Re: [12.30.0] Not possible to spawn entity-ghost?

Posted: Tue Apr 26, 2016 10:05 pm
by Stray_Pyramid
Would I be correct in going:

Code: Select all

new_tree.time_to_live = 60 * 60 * 5
The time to live value does not change when I do this.