[12.30.0] Not possible to spawn entity-ghost?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Stray_Pyramid
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Feb 21, 2014 10:24 pm
Contact:

[12.30.0] Not possible to spawn entity-ghost?

Post 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?

Stray_Pyramid
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Feb 21, 2014 10:24 pm
Contact:

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

Post by Stray_Pyramid »

Turns out the ghost exists on the tick that it was created, and then disappears the next tick.

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

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

Post by DaveMcW »

Be sure you have at least one ghost time-to-live tech.

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

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Stray_Pyramid
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Feb 21, 2014 10:24 pm
Contact:

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

Post 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.

Stray_Pyramid
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Feb 21, 2014 10:24 pm
Contact:

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

Post 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.

Post Reply

Return to “Modding discussion”