[Solved] Adding a Linked-Chest as an Item vs a Linked Container

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] Adding a Linked-Chest as an Item vs a Linked Container

Post by Job »

Hello,

I could not find the mod I was seeking, so I decided to try and build it myself. I started (with what I think is) basic, by just addingt the item I want: linked-chest https://www.reddit.com/r/factorio/comme ... le_in_the/

I used the tutorial on the Wiki https://wiki.factorio.com/Tutorial:Modd ... al/Gangsir as a starting point.

I got the fireArmor from the example working sans the control.lua file as that went beyond the scope of what I was trying to do for Step 1. I then tried replacing the necessary variables to add linked-chests. I got various errors as I worked through it, but I kept hitting a wall when trying to load the game with:
warpchesterror.JPG
warpchesterror.JPG (26.8 KiB) Viewed 1164 times
Here is my code:

Code: Select all

--item.lua

local warpChest = table.deepcopy(data.raw["linked-container"]["linked-chest"])

warpChest.name = "warp-chest"
warpChest.icons = {
  {
    icon = warpChest.icon,
    tint = {r=1,g=0,b=0,a=0.3}
  },
}

local recipe = table.deepcopy(data.raw["recipe"]["heavy-armor"])
recipe.enabled = true
recipe.name = "warp-chest"
recipe.ingredients = {{"copper-plate",200},{"steel-plate",50}}
recipe.result = "warp-chest"

data:extend{warpChest,recipe}
I finally got it to "work" by replacing "linked-container" with "item"

When I loaded into the game, I got this (red chest is the new item in the unsorted category):
workingish.JPG
workingish.JPG (164.9 KiB) Viewed 1164 times
This definitely felt like progress. However, when I would place one of those chests on the ground in the game, it would "change" to a normal linked chest. i.e. The custom color would go away, and the item-name would change back to the default.

The other mods I could find that dealt with linked-chests seemed to use "linked-container" in the deepcopy, but more indirectly, so I can't look at an easy 1:1 working example to compare.

I would like to be able to add modified linked-chest(s) as a first step that "stay" modified.

Several notes:
  • I am aware that linked-chests are not a normal item and that I am modifying a hidden item that requires using the editor/console (see Reddit link above).
  • Apologies if I am conflating 2 or more issues in a single post.
  • I realize a lot of people consider linked chests to defeat a lot of the purpose of Factorio. I am trying to build a mod with that in mind.
  • My end goal is to have linked-chests that can be named for different purposes vs the checkbox GUI. Based on my forum deep dive, I don't think that will be possible, but I would like to at least figure out this "step 1".
Thank you for anyone who takes the time to read and respond. If I can provide additional information, please let me know.

Edit: Clarity.
Last edited by Job on Fri Oct 15, 2021 5:46 am, edited 1 time in total.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Adding a Linked-Chest as an Item vs a Linked Container

Post by DaveMcW »

You need 3 prototypes to add most things to the game:
  • Recipe
  • Item
  • Entity
Gangsir's tutorial is misleading, because armor is special and does not require a separate "entity".

You tried copying data.raw["linked-container"]["linked-chest"] and data.raw["item"]["linked-chest"]. The solution is to copy BOTH to create an entity and an item. You also need to set item.place_result to the name of your entity.

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

Re: Adding a Linked-Chest as an Item vs a Linked Container

Post by Job »

Thank you DaveMcW.

I have not quite got it where I want it, but your insights were extremely helpful for getting me on the right track.

Marking as solved.

Post Reply

Return to “Modding help”