Context
The idea behind MOD is to create recipes that “compact” and “decompact” items. Compacting is done by a machine, and decompressing is done by the same machine, but also by the player with their hands.The problem
There is no problem when creating one of the compacted objects.This can be seen in the examples below, in the number of transport belts that can be manufactured.
It works with only iron plates: Yes
It works with only iron gears: Yes
However, when there are several objects at the same time, intermediate manufacturing is disabled.
This can be seen in the following example.
It works with both active: No
What did you expect to happen?
That compressed iron plates would be treated as iron plates.In other words,
each compressed iron plate is equivalent to 1,000 normal iron plates, so you should be able to create 500 iron gears or 333 transport bells or any other option.
Functional code to test
I have simplified the idea in the code below to highlight the problem I am having.Code: Select all
--- --- --- --- --- --- --- --- --- --- --- --- --- ---
---> data.lua
--- --- --- --- --- --- --- --- --- --- --- --- --- ---
local function DeepCopy(value)
if type(value) ~= "table" then return value end
local Output = {}
for Key, Value in pairs(value) do
Output[Key] = DeepCopy(Value)
end
return Output
end
local function getSignal(signal)
return data.raw["virtual-signal"]["signal-" .. signal .. ""].icon
end
data:extend({
{ type = "recipe-category", name = "zzzYAIM904-do" },
{ type = "recipe-category", name = "zzzYAIM904-undo" }
})
table.insert(data.raw["character"].character.crafting_categories, "zzzYAIM904-undo")
table.insert(data.raw["god-controller"].default.crafting_categories, "zzzYAIM904-undo")
table.insert(data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories, "zzzYAIM904-do")
table.insert(data.raw["assembling-machine"]["assembling-machine-1"].crafting_categories, "zzzYAIM904-undo")
for _, name in pairs({
"iron-plate",
"iron-gear-wheel",
}) do
local item = data.raw.item[name]
local Item = DeepCopy(item)
Item.name = "zzzYAIM904-" .. Item.name
Item.localised_name = { "", "YAIM904 ", { "item-name." .. name } }
Item.icons = {
{ icon = getSignal("pink") },
{
icon = item.icon,
icon_size = item.icon_size
}
}
local URecipe = {}
URecipe.type = "recipe"
URecipe.name = "zzzYAIM904-u-" .. item.name
URecipe.localised_name = { "", { "item-name." .. name } }
URecipe.category = "zzzYAIM904-undo"
URecipe.ingredients = { {
type = "item",
name = Item.name,
amount = 1
} }
URecipe.results = { {
type = "item",
name = name,
amount = 1000
} }
URecipe.icons = {
{ icon = getSignal("green") },
{
icon = item.icon,
icon_size = item.icon_size
}
}
local DRecipe = {}
DRecipe.type = "recipe"
DRecipe.name = "zzzYAIM904-d-" .. item.name
DRecipe.localised_name = { "", "YAIM904 ", { "item-name." .. name } }
DRecipe.category = "zzzYAIM904-do"
DRecipe.results = { {
type = "item",
name = Item.name,
amount = 1
} }
DRecipe.ingredients = { {
type = "item",
name = name,
amount = 1000
} }
DRecipe.icons = {
{ icon = getSignal("red") },
{
icon = item.icon,
icon_size = item.icon_size
}
}
data:extend({ Item, DRecipe, URecipe })
end
--- --- --- --- --- --- --- --- --- --- --- --- --- ---
This is a problem I've had for a long time, and I really want to solve it.


