[Solved] Possible to set link_id in data.lua?

Place to get help with not working mods / modding interface.
Post Reply
Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

[Solved] Possible to set link_id in data.lua?

Post 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
Last edited by Job on Tue Oct 19, 2021 7:57 pm, edited 1 time in total.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Possible to set link_id in data.lua?

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

Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

Re: Possible to set link_id in data.lua?

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

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Possible to set link_id in data.lua?

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

Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

Re: Possible to set link_id in data.lua?

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

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Possible to set link_id in data.lua?

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

Job
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Oct 14, 2021 3:29 pm
Contact:

Re: Possible to set link_id in data.lua?

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

Post Reply

Return to “Modding help”