Skip to content

Commit b29888e

Browse files
authored
Merge pull request jodli#7 from Silari/Linked-Chest-Belt
Add linked chest/belts
2 parents 7951578 + 40860b0 commit b29888e

File tree

7 files changed

+116
-2
lines changed

7 files changed

+116
-2
lines changed

changelog.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
Version: 1.8.1
33
Date: 2023-02-22
44
Features:
5-
- Added a version of the Loader1x1 - same speed/usage as the other loader, but 1x1 in size, enabling smaller builds.
65
- Added a recipe for the vanilla infinity chest, as well as requester and provider variants. Setting the infinity filters will cause them to always maintain supplies of at most/at least/exactly the amount set, and a checkbox will void any contents that aren't in the infinity filters. Since they are vanilla entities, they'll be handled in engine rather than via LUA. They serve as excellent replacements to the duplicator chest and duplicator provider chest.
76
- Many of the chests were converted to use this prototype internally to drastically reduce UPS costs - details are below.
7+
- Added a version of the Loader1x1 - same speed/usage as the other loader, but 1x1 in size, enabling smaller builds.
8+
- Added a version of the linked chest. Any two chests that are set to the same id, via the checkboxes seen when opening them, will share the inventory contents.
9+
- Added a version of linked belts. Copying the settings of one and pasting it to another will set them as an input/output pair. Speed is the same as the loaders to maintain throughput.
810
Changes:
911
- Removed belt immunity equipment. This is a vanilla item now, no need for a recipe. We don't have one for all the other regular items.
1012
- Removed fluid-unknown from fluid source recipes. It's not a real fluid and there's no need for it.

defines.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ creative_mode_defines.names.entities = {
100100
void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
101101
super_loader = creative_mode_defines.name_prefix .. "super-loader",
102102
super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
103+
linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
104+
linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
103105
creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
104106
duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
105107
void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
@@ -164,6 +166,8 @@ creative_mode_defines.names.items = {
164166
void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
165167
super_loader = creative_mode_defines.name_prefix .. "super-loader",
166168
super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
169+
linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
170+
linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
167171
creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
168172
duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
169173
void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
@@ -248,6 +252,8 @@ creative_mode_defines.names.recipes = {
248252
void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
249253
super_loader = creative_mode_defines.name_prefix .. "super-loader",
250254
super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
255+
linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
256+
linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
251257
creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
252258
duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
253259
void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",

locale/en/base.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ creative-mod_void-chest=A chest that removes all items inside it.\nClears conten
6868
creative-mod_void-storage-chest=A storage chest that removes all items inside it.\nClears contents upon removed.
6969
creative-mod_super-loader=A super fast loader that can easily compress the transport belt in front of it. When used with infinity chests, you have a low-performance-cost solution for testing throughput with transport a belt system.
7070
creative-mod_super-loader2=A super fast loader1x1 that can easily compress the transport belt in front of it. When used with infinity chests, you have a low-performance-cost solution for testing throughput with transport a belt system.
71+
creative-mod_linked-chest=Shares an inventory with other linked chests that have the setting. Set the ID by checking the boxes - any chests where the same boxes are checked/unchecked are linked.
72+
creative-mod_linked-belt=A belt that can connect to another belt of the same type, anywhere on any surface. To setup, copy the settings (__CONTROL__copy-entity-settings__) of the belt you wish to be the input then paste them (__CONTROL__paste-entity-settings__) on the belt you want to be the output.
7173
creative-mod_creative-cargo-wagon=A cargo wagon that contains all items in the game and can auto refill itself. Its last slot can be used for voiding unwanted items. (May need to place more than one to get more items.)\nClears contents upon removal.
7274
creative-mod_duplicating-cargo-wagon=A cargo wagon that duplicates the item in its first slot.\nClears contents upon removal.
7375
creative-mod_void-cargo-wagon=A cargo wagon that removes all items inside it.\nClears contents upon removal.

prototypes/entity.lua

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,53 @@ local function logistic_container(entity_name, item_name, icon_name, picture_nam
351351
}
352352
end
353353

354+
-- Makes a new linked chest
355+
local function linkedchest(entity_name, item_name, inventory_size)
356+
--We make minimal changes to this, we just want it to be our own entity in case anything messes with the vanilla one.
357+
local newchest = table.deepcopy(data.raw["linked-container"]["linked-chest"])
358+
newchest.type = "linked-container"
359+
newchest.name = entity_name
360+
newchest.flags = {"placeable-player", "player-creation"}
361+
newchest.minable = {
362+
mining_time = 0.5,
363+
result = item_name
364+
}
365+
newchest.max_health = 150
366+
newchest.fast_replaceable_group = "container"
367+
newchest.gui_mode = "admins"
368+
newchest.additional_pastable_entities = additional_pastable_entities
369+
if inventory_size then
370+
newchest.inventory_size = inventory_size
371+
end
372+
newchest.erase_contents_when_mined = true
373+
newchest.circuit_wire_max_distance = 1000
374+
newchest.localised_name = {"entity-name.linked-chest"}
375+
return newchest
376+
end
377+
378+
-- Makes a new linked belt
379+
local function linkedbelt(entity_name, item_name)
380+
local newbelt = table.deepcopy(data.raw["linked-belt"]["linked-belt"])
381+
newbelt.type = "linked-belt"
382+
newbelt.name = entity_name
383+
newbelt.flags = {"placeable-player", "player-creation"}
384+
newbelt.minable = {
385+
mining_time = 0.5,
386+
result = item_name
387+
}
388+
newbelt.max_health = 150
389+
newbelt.fast_replaceable_group = "container"
390+
newbelt.gui_mode = "admins"
391+
newbelt.additional_pastable_entities = additional_pastable_entities
392+
newbelt.circuit_wire_max_distance = 1000
393+
newbelt.localised_name = {"entity-name.linked-belt"}
394+
newbelt.allow_copy_paste = true
395+
newbelt.additional_pastable_entities = {entity_name}
396+
newbelt.speed = 1
397+
398+
return newbelt
399+
end
400+
354401
-- Generates data for cargo wagon according to the given data.
355402
local function cargo_wagon(entity_name, item_name, tint, additional_pastable_entities, inventory_size)
356403
return {
@@ -1233,6 +1280,10 @@ data:extend({
12331280
},
12341281
ending_patch = ending_patch_prototype
12351282
},
1283+
-- Linked Chest
1284+
linkedchest(creative_mode_defines.names.entities.linked_chest, creative_mode_defines.names.items.linked_chest),
1285+
-- Linked Belt
1286+
linkedbelt(creative_mode_defines.names.entities.linked_belt, creative_mode_defines.names.items.linked_belt),
12361287
-- Creative Cargo Wagon
12371288
cargo_wagon(creative_mode_defines.names.entities.creative_cargo_wagon,
12381289
creative_mode_defines.names.items.creative_cargo_wagon, {

prototypes/item.lua

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,34 @@ data:extend(
161161
icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
162162
flags = {flags_quickbar},
163163
subgroup = creative_mode_defines.names.item_subgroups.items,
164-
order = "i",
164+
order = "i1",
165165
place_result = creative_mode_defines.names.entities.super_loader2,
166166
stack_size = 50
167167
},
168+
{
169+
-- Linked Chest
170+
type = "item",
171+
name = creative_mode_defines.names.items.linked_chest,
172+
icon_size = data.raw.item["linked-chest"].icon_size,
173+
icon = data.raw.item["linked-chest"].icon,
174+
flags = {flags_quickbar},
175+
subgroup = creative_mode_defines.names.item_subgroups.items,
176+
order = "a5",
177+
place_result = creative_mode_defines.names.entities.linked_chest,
178+
stack_size = 50
179+
},
180+
{
181+
-- Linked Belt
182+
type = "item",
183+
name = creative_mode_defines.names.items.linked_belt,
184+
icon_size = data.raw.item["linked-belt"].icon_size,
185+
icon = data.raw.item["linked-belt"].icon,
186+
flags = {flags_quickbar},
187+
subgroup = creative_mode_defines.names.item_subgroups.items,
188+
order = "i2",
189+
place_result = creative_mode_defines.names.entities.linked_belt,
190+
stack_size = 50
191+
},
168192
-----------------------------------------------------------------------------
169193

170194
{

prototypes/recipe.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ data:extend(
110110
result = creative_mode_defines.names.items.super_loader2,
111111
enabled = false
112112
},
113+
{
114+
-- Linked Chest
115+
type = "recipe",
116+
name = creative_mode_defines.names.recipes.linked_chest,
117+
ingredients = {},
118+
result = creative_mode_defines.names.items.linked_chest,
119+
enabled = false
120+
},
121+
{
122+
-- Linked Belt
123+
type = "recipe",
124+
name = creative_mode_defines.names.recipes.linked_belt,
125+
ingredients = {},
126+
result = creative_mode_defines.names.items.linked_belt,
127+
enabled = false
128+
},
113129
-----------------------------------------------------------------------------
114130

115131
{

scripts/events.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,19 @@ local function on_entity_settings_pasted(event)
509509
item_void.on_entity_copied_pasted(event.source, event.destination)
510510
return
511511
end
512+
513+
if event.source.name == creative_mode_defines.names.entities.linked_belt and
514+
event.destination.name == creative_mode_defines.names.entities.linked_belt then
515+
-- Remove their previous links, if any.
516+
event.source.disconnect_linked_belts()
517+
event.destination.disconnect_linked_belts()
518+
-- Setup these belts as input and output, respectively.
519+
event.source.linked_belt_type = "input"
520+
event.destination.linked_belt_type = "output"
521+
-- then connect them to each other. This overrides any previous settings.
522+
event.source.connect_linked_belts(event.destination)
523+
return
524+
end
512525
end
513526

514527
-- Callback of the on_player_created event, which is invoked after a player is created.

0 commit comments

Comments
 (0)