I am trying to replace the "stone" doodad entity with a tree entity, so that it can be picked up with robots, mined, show it's loot, hardness, etc, etc.
However, while I made the new prototype, I cannot set the old one to nil, since it causes an error. I cannot name the new one "stone" as well, as it causes another error, and it claims to create a collision rather than overriding it since the type is different. As a result, it ended up named "stone2".
I looked over the migration script guide, but it doesn't clearly state how to override one entity with another one.
I was then going to search for all matching entities and replace them, but I cannot find a filter with no area argument.
Entity Migration
- Ranakastrasz
- Smart Inserter
- Posts: 2179
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Entity Migration
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
- Ranakastrasz
- Smart Inserter
- Posts: 2179
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Entity Migration
Code: Select all
for _, surface in ipairs(game.surfaces) do
for _, entity in ipairs(game.surface.find_entities_filtered{
area={{-1000000, -1000000},
{1000000, 1000000}},
name="stone-rock"})
do
surface.create_entity{name = "stone-rock-2", position = entity.position, direction = defines.direction.north}
entity.destroy()
end
end
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Entity Migration
If you want to get ahold of me I'm almost always on Discord.
- Ranakastrasz
- Smart Inserter
- Posts: 2179
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Entity Migration
Will that actually work? I thought that only applied if you were renaming something of the same type.
Will check.
That did not work
My Prototype definition file
Will check.
Code: Select all
{
"entity":
[
["stone-rock", "stone-rock-2"],
]
}
My Prototype definition file
Code: Select all
--data.raw["simple-entity"]["stone-rock"] = nil
data.raw["simple-entity"]["stone-rock"].autoplace = nil
data:extend(
{
{
type = "tree",
name = "stone-rock-2",
flags = {"placeable-neutral", "placeable-off-grid", "not-on-map"},
minable =
{
count = 25,
hardness = 0.8,
mining_particle = "stone-particle",
mining_time = 5,
result = "stone"
},
icon = "__base__/graphics/icons/stone-rock.png",
subgroup = "grass",
order = "b[decorative]-k[stone-rock]-a[big]",
collision_box = {{-1.1, -1.1}, {1.1, 1.1}},
selection_box = {{-1.3, -1.3}, {1.3, 1.3}},
render_layer = "object",
max_health = 200,
resistances =
{
{
type = "fire",
percent = 100
}
},
autoplace =
{
order = "a[doodad]-a[rock]",
peaks =
{
{
influence = 0.0002
},
{
influence = 0.002;
min_influence = 0,
elevation_optimal = 30000,
elevation_range = 23000,
elevation_max_range = 30000,
}
}
},
pictures =
{
{
filename = "__base__/graphics/entity/decorative/stone-rock/stone-rock-01.png",
width = 76,
height = 60,
shift = {0.1, 0}
},
{
filename = "__base__/graphics/entity/decorative/stone-rock/stone-rock-02.png",
width = 83,
height = 86,
shift = {0.2, 0}
},
{
filename = "__base__/graphics/entity/decorative/stone-rock/stone-rock-03.png",
width = 126,
height = 98,
shift = {0.7, 0}
},
{
filename = "__base__/graphics/entity/decorative/stone-rock/stone-rock-04.png",
width = 92,
height = 108,
shift = {0.1, 0}
},
{
filename = "__base__/graphics/entity/decorative/stone-rock/stone-rock-05.png",
width = 140,
height = 99,
shift = {0.5, 0}
}
}
}
})
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Entity Migration
You have to put the migration file in the correct location and yes it does work to migrate entity types (chest -> assembling machine) and so on.
It goes in the folder migrations and can have any name normally with the extension: json
It goes in the folder migrations and can have any name normally with the extension: json
If you want to get ahold of me I'm almost always on Discord.