Page 1 of 1
[Solved] Possible to set link_id in data.lua?
Posted: Fri Oct 15, 2021 7:00 pm
by Job
For the mod I am working on, I was trying to define the link_id as part of a new item/entity. For example on the entity:
Code: Select all
local WarpChest = util.table.deepcopy(data.raw["linked-container"]["linked-chest"])
WarpChest.name = "warp-chest"
WarpChest.minable.result = "warp-chest"
WarpChest.inventory_size = 80
WarpChest.link_id = 4096
Everything else works, except I can not force it to start with a certain link_id. My one thought is that maybe I can't do this at the data stage?
Thank you for any thoughts or insights.
Referential links
https://wiki.factorio.com/Prototype/LinkedContainer
https://lua-api.factorio.com/latest/Lua ... ty.link_id
Re: Possible to set link_id in data.lua?
Posted: Sat Oct 16, 2021 12:11 am
by Silari
Don't believe you can do that, no. However it also shouldn't matter - per the wiki page on LinkedContainer: "only containers with the same ID, same prototype name and same force will share inventories", so even with the default value any that are built should share their inventory and never with anything that isn't a warp-chest. Pretty sure they defaulted to linkid 0 when I played around with them.
You can change the
gui-mode to 'none' to prevent anyone from changing the ID per the docs.
Re: Possible to set link_id in data.lua?
Posted: Sat Oct 16, 2021 12:54 am
by Job
Silari wrote: ↑Sat Oct 16, 2021 12:11 am
Don't believe you can do that, no. However it also shouldn't matter - per the wiki page on LinkedContainer: "only containers with the same ID, same prototype name and same force will share inventories", so even with the default value any that are built should share their inventory and never with anything that isn't a warp-chest. Pretty sure they defaulted to linkid 0 when I played around with them.
Thank you for the response, Silari.
It does matter for purposes of my mod since I was going to create multiple warp chests, and I wanted to make sure each of them remained linked to its type. It can be done in the scripting, but was hoping to define it that way at the data stage.
Since the ID won't change, the force is the same for my case, and my understanding is the prototype name would be the same in this set up, it looks like I'll have to do this via scripting.
Re: Possible to set link_id in data.lua?
Posted: Sat Oct 16, 2021 2:33 am
by mrvn
Job wrote: ↑Sat Oct 16, 2021 12:54 am
Silari wrote: ↑Sat Oct 16, 2021 12:11 am
Don't believe you can do that, no. However it also shouldn't matter - per the wiki page on LinkedContainer: "only containers with the same ID, same prototype name and same force will share inventories", so even with the default value any that are built should share their inventory and never with anything that isn't a warp-chest. Pretty sure they defaulted to linkid 0 when I played around with them.
Thank you for the response, Silari.
It does matter for purposes of my mod since I was going to create multiple warp chests, and I wanted to make sure each of them remained linked to its type. It can be done in the scripting, but was hoping to define it that way at the data stage.
Since the ID won't change, the force is the same for my case, and my understanding is the prototype name would be the same in this set up, it looks like I'll have to do this via scripting.
If the prototype is the same then they all would have linked_id = 4096 and you would have to change it via script anyway. So nothing lost there.
Re: Possible to set link_id in data.lua?
Posted: Sat Oct 16, 2021 2:38 am
by Job
mrvn wrote: ↑Sat Oct 16, 2021 2:33 am
If the prototype is the same then they all would have linked_id = 4096 and you would have to change it via script anyway. So nothing lost there.
Ah, I may not have explained myself well.
I was going to create, for example, 3 warp chests. e.g. WarpChest1, WarpChest2, WarpChest3
I want to make sure WarpChest1 has a certain link_id so that it always connects to other WarpChest1's, but not WarpChest2 or WarpChest3.
Re: Possible to set link_id in data.lua?
Posted: Sat Oct 16, 2021 3:10 am
by mrvn
That would then be 3 prototypes and WarpChest1 won't link with WarpChest2.
I think you should just try it. According to the docs it should just work without you having to set a link_id at all.
Re: Possible to set link_id in data.lua?
Posted: Tue Oct 19, 2021 7:57 pm
by Job
mrvn wrote: ↑Sat Oct 16, 2021 3:10 am
That would then be 3 prototypes and WarpChest1 won't link with WarpChest2.
I think you should just try it. According to the docs it should just work without you having to set a link_id at all.
Thank you mrvn. They do appear to be operating independently (my understanding was incorrect). My next step is try to iterate multiple versions/colors. Appreciate your help.