Entities with the same name

Place to get help with not working mods / modding interface.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Entities with the same name

Post by Pi-C »

I've always wondered what would happen if there were two entities of a different type, but with the same name. Now that there's a new mod that creates a spider-vehicle prototype for a given car prototype, this isn't just a theoretical question anymore:
same_name.png
same_name.png (65.87 KiB) Viewed 631 times
As they are defined as data.raw.car.car and data.raw["spider-vehicle"].car, they are in separate name spaces, so creating the prototypes is not a problem. But what about the control stage? For example, LuaSurface.create_entity allows to specify the name of the entity to be created -- is there any rule to determine whether

Code: Select all

surface.create_entity{ name = "car", position = {player.position.x - 1, player.position.y - 1} }
will create the car or the spider-vehicle?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Entities with the same name

Post by Bilka »

The internal name of that entity isn't car. Only the localised name is.
Image
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Entities with the same name

Post by Pi-C »

Bilka wrote:
Wed Jul 20, 2022 3:42 pm
The internal name of that entity isn't car. Only the localised name is.
Oh, darn … I should have made that one more click! :-)

Also, this:

Code: Select all

local test = table.deepcopy(data.raw["spider-vehicle"]["spidertron"])
test.name = "car"
data:extend({test})
results in

Code: Select all

   3.501 Error ModManager.cpp:1558: Error while loading entity prototype "car" (spider-vehicle): Prototype "car" registered twice
So, the game already ensures that entity names will be unique even across entity types -- excellent! Anyway, thanks for the pointer, and sorry to waste your time! :mrgreen:
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding help”