Hi,
sorry in advance for my bad english.
I try to write my first mod for factorio : it will ask the player to build a custom assembly machine at a random place on the map. Which should be the only spot where it can be build.
So far i was able to create my custom assembly machine and a new ore to feed it.
Now i try to spawn a ghost of this building on the map ... but i'm unable to ... even with roboport up and running ... i cannot change the entity type to "ghost" because it's a read only property, and i can't find any existing mod using this kind of behavior. (nor proper documentation ^^)
So i'm here to ask some help, perhaps it's the wrong approach, but i would really like to use a ghost entity (not minable) placed on the map right after map generation (or mod activation).
Thanks in advance for any helping hand.
Ghost entity used as "building mission"
-
- Manual Inserter
- Posts: 2
- Joined: Mon Mar 07, 2016 11:53 am
- Contact:
Ghost entity used as "building mission"
Last edited by Filendrick on Tue Mar 08, 2016 12:20 pm, edited 2 times in total.
Re: Ghost entity used as "building mission"
You don't change the entity type to ghost after placing a building, you need to create a ghost entity in the first place. For that you need to pass name="entity-ghost" and inner_name="actual-entity" to the create_entity call. Note that this ghost will time out after a while as usual.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Ghost entity used as "building mission"
unless you set the timeout as wellprg wrote:You don't change the entity type to ghost after placing a building, you need to create a ghost entity in the first place. For that you need to pass name="entity-ghost" and inner_name="actual-entity" to the create_entity call. Note that this ghost will time out after a while as usual.
-
- Manual Inserter
- Posts: 2
- Joined: Mon Mar 07, 2016 11:53 am
- Contact:
Re: Ghost entity used as "building mission"
Oh i see now,
Thanks you very much to both of you.
edit : well ... i must miss something ... i supposed that an entity ghost should inherit some data from "inner" entity (like picture at least) .... it seems not ....
i'm still unable to spawn this damn ghost ^^
i'm pretty sure it's a silly mistake...
Anyone have an example of how to spawn any ghost building ?
some of my code :
This code is supposed to spawn a ghost when placing my custom assembly.
weapon-dealer entity :
Thanks you very much to both of you.
edit : well ... i must miss something ... i supposed that an entity ghost should inherit some data from "inner" entity (like picture at least) .... it seems not ....
i'm still unable to spawn this damn ghost ^^
i'm pretty sure it's a silly mistake...
Anyone have an example of how to spawn any ghost building ?
some of my code :
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
if event.created_entity.name == "weapon-dealer" then
entity = event.created_entity
surf = entity.surface
posX = entity.position.x +5
posY = entity.position.y +5
local new_entity = {
name = "entity-ghost",
inner_name = "weapon-dealer", --see below
position = {posX,posY },
force = entity.force }
game.surfaces['nauvis'].create_entity(new_entity)
weapon-dealer entity :
Code: Select all
local entity={
type = "assembling-machine",
name = "weapon-dealer",
icon = "__Filendrick_mod__/graphics/weapon-dealer-icon.png",
flags = {"placeable-neutral", "placeable-player", "player-creation"},
minable = {hardness = 0.2, mining_time = 0.5, result = "weapon-dealer"},
max_health = 250,
inventory_size = 3,
corpse = "big-remnants",
dying_explosion = "medium-explosion",
resistances =
{
{
type = "fire",
percent = 70
}
},
fluid_boxes =
{
{
production_type = "input",
pipe_picture = assembler2pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 10,
base_level = -1,
pipe_connections = {{ type="input", position = {0, -2} }}
},
{
production_type = "output",
pipe_picture = assembler2pipepictures(),
pipe_covers = pipecoverspictures(),
base_area = 10,
base_level = 1,
pipe_connections = {{ type="output", position = {0, 2} }}
},
off_when_no_fluid_recipe = true
},
collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
animation =
{
filename = "__base__/graphics/entity/assembling-machine-2/assembling-machine-2.png",
priority = "high",
width = 113,
height = 99,
frame_count = 32,
line_length = 8,
shift = {0.4, -0.06}
},
open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.85 },
close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
working_sound =
{
sound = {
{
filename = "__base__/sound/assembling-machine-t2-1.ogg",
volume = 0.8
},
{
filename = "__base__/sound/assembling-machine-t2-2.ogg",
volume = 0.8
},
},
idle_sound = { filename = "__base__/sound/idle1.ogg", volume = 0.6 },
apparent_volume = 1.5,
},
crafting_categories = {"filendrick_recipes"},
crafting_speed = 0.75,
energy_source =
{
type = "electric",
usage_priority = "secondary-input",
emissions = 0.04 / 2.5
},
energy_usage = "150kW",
ingredient_count = 1
}
}