Code: Select all
For each type of item used as an ingredient in the recycled item's main recipe, the number of items returned by the recycler is decided by
⌊0.25 * i / o + r ], where i is the number of items used as ingredients, o is the number of items returned by the recipe, and r
is a random number that is greater than or equal to 0 but less than 1. On average, this returns exactly 25% of the items needed to craft one item of the same type as the recycled item. For example, recycling a processing unit always gives 5 electronic circuits while having a 50% chance of returning one advanced circuit.
To create the recipe used by the recycler:
- Check the recipe used to create the item. See how many items are created by one craft.
- Multiply this number by 4. ("final_probability")
For every non-fluid ingredient used to create this item: - Original count divided by final_probability = number returned.
- Original count MOD final_probability , to get a remainder. Remainder divided by final_probability = extra_fraction
I believe this is important to spell out this more more accurately in the wiki.
Supporting test LUA outputs:
Code: Select all
multiplier [ number of items crafted by source recipe ] = 1
Looping through ingredients...
Checking ingredient : electronic-circuit
final_amount [number of this item in the source recipe ] = 20
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 5.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : electronic-circuit
Checking ingredient : advanced-circuit
final_amount [number of this item in the source recipe ] = 2
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 2
(updated) final_amount [ original final_amount / final_probability ] = 0.5
final_extra_fraction [ remainder / final_probability ] = 0.5
Done with ingredient : advanced-circuit
Checking ingredient : sulfuric-acid
Final recycling recipe for processing-unit :
table: 0x55cdf86a3c90 {
[subgroup] => "other"
[category] => "recycling"
[unlock_results] => false
[type] => "recipe"
[results] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf869cdb0 {
[extra_count_fraction] => 0.0
[amount] => 5.0
[name] => "electronic-circuit"
[type] => "item"
}
[2] => table: 0x55cdf869cdb0 {
[extra_count_fraction] => 0.5
[amount] => 0.5
[name] => "advanced-circuit"
[type] => "item"
}
}
[allow_decomposition] => false
[localised_name] => table: 0x55cdf86a3c90 {
[1] => "recipe-name.recycling"
[2] => "processing-unit"
}
[name] => "processing-unit-recycling"
[ingredients] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf869cc90 {
[amount] => 1
[name] => "processing-unit"
[type] => "item"
}
}
[energy_required] => 0.625
[hidden] => true
}
=====
multiplier [ number of items crafted by source recipe ] = 1
Looping through ingredients...
Checking ingredient : radar
final_amount [number of this item in the source recipe ] = 1
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 1
(updated) final_amount [ original final_amount / final_probability ] = 0.25
final_extra_fraction [ remainder / final_probability ] = 0.25
Done with ingredient : radar
Checking ingredient : calcite
final_amount [number of this item in the source recipe ] = 1
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 1
(updated) final_amount [ original final_amount / final_probability ] = 0.25
final_extra_fraction [ remainder / final_probability ] = 0.25
Done with ingredient : calcite
Checking ingredient : tungsten-plate
final_amount [number of this item in the source recipe ] = 4
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 1.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : tungsten-plate
Checking ingredient : explosives
final_amount [number of this item in the source recipe ] = 8
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 2.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : explosives
Final recycling recipe for artillery-shell :
table: 0x55cdf86a3c90 {
[subgroup] => "other"
[category] => "recycling"
[unlock_results] => false
[type] => "recipe"
[results] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86a8290 {
[extra_count_fraction] => 0.25
[amount] => 0.25
[name] => "radar"
[type] => "item"
}
[2] => table: 0x55cdf86a8290 {
[extra_count_fraction] => 0.25
[amount] => 0.25
[name] => "calcite"
[type] => "item"
}
[3] => table: 0x55cdf86a8290 {
[extra_count_fraction] => 0.0
[amount] => 1.0
[name] => "tungsten-plate"
[type] => "item"
}
[4] => table: 0x55cdf86a8290 {
[extra_count_fraction] => 0.0
[amount] => 2.0
[name] => "explosives"
[type] => "item"
}
}
[allow_decomposition] => false
[localised_name] => table: 0x55cdf86a3c90 {
[1] => "recipe-name.recycling"
[2] => "artillery-shell"
}
[name] => "artillery-shell-recycling"
[ingredients] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86a83a0 {
[amount] => 1
[name] => "artillery-shell"
[type] => "item"
}
}
[energy_required] => 0.9375
[hidden] => true
}
=====
multiplier [ number of items crafted by source recipe ] = 2
Looping through ingredients...
Checking ingredient : tungsten-plate
final_amount [number of this item in the source recipe ] = 40
final_probability [4 * multiplier ] = 8
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 5.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : tungsten-plate
Checking ingredient : express-underground-belt
final_amount [number of this item in the source recipe ] = 2
final_probability [4 * multiplier ] = 8
remainder [ final_amount % final_probability ] = 2
(updated) final_amount [ original final_amount / final_probability ] = 0.25
final_extra_fraction [ remainder / final_probability ] = 0.25
Done with ingredient : express-underground-belt
Checking ingredient : lubricant
Final recycling recipe for turbo-underground-belt :
table: 0x55cdf86a3c90 {
[subgroup] => "other"
[category] => "recycling"
[unlock_results] => false
[type] => "recipe"
[results] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86aa490 {
[extra_count_fraction] => 0.0
[amount] => 5.0
[name] => "tungsten-plate"
[type] => "item"
}
[2] => table: 0x55cdf86aa490 {
[extra_count_fraction] => 0.25
[amount] => 0.25
[name] => "express-underground-belt"
[type] => "item"
}
}
[allow_decomposition] => false
[localised_name] => table: 0x55cdf86a3c90 {
[1] => "recipe-name.recycling"
[2] => "turbo-underground-belt"
}
[name] => "turbo-underground-belt-recycling"
[ingredients] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86aa4d0 {
[amount] => 1
[name] => "turbo-underground-belt"
[type] => "item"
}
}
[energy_required] => 0.125
[hidden] => true
}
=====
multiplier [ number of items crafted by source recipe ] = 1
Looping through ingredients...
Checking ingredient : steel-plate
final_amount [number of this item in the source recipe ] = 1000
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 250.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : steel-plate
Checking ingredient : concrete
final_amount [number of this item in the source recipe ] = 1000
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 250.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : concrete
Checking ingredient : pipe
final_amount [number of this item in the source recipe ] = 100
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 25.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : pipe
Checking ingredient : processing-unit
final_amount [number of this item in the source recipe ] = 200
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 50.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : processing-unit
Checking ingredient : electric-engine-unit
final_amount [number of this item in the source recipe ] = 200
final_probability [4 * multiplier ] = 4
remainder [ final_amount % final_probability ] = 0
(updated) final_amount [ original final_amount / final_probability ] = 50.0
final_extra_fraction [ remainder / final_probability ] = 0.0
Done with ingredient : electric-engine-unit
Final recycling recipe for rocket-silo :
table: 0x55cdf86a3c90 {
[subgroup] => "other"
[category] => "recycling"
[unlock_results] => false
[type] => "recipe"
[results] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86abbb0 {
[extra_count_fraction] => 0.0
[amount] => 250.0
[name] => "steel-plate"
[type] => "item"
}
[2] => table: 0x55cdf86abbb0 {
[extra_count_fraction] => 0.0
[amount] => 250.0
[name] => "concrete"
[type] => "item"
}
[3] => table: 0x55cdf86abbb0 {
[extra_count_fraction] => 0.0
[amount] => 25.0
[name] => "pipe"
[type] => "item"
}
[4] => table: 0x55cdf86abbb0 {
[extra_count_fraction] => 0.0
[amount] => 50.0
[name] => "processing-unit"
[type] => "item"
}
[5] => table: 0x55cdf86abbb0 {
[extra_count_fraction] => 0.0
[amount] => 50.0
[name] => "electric-engine-unit"
[type] => "item"
}
}
[allow_decomposition] => false
[localised_name] => table: 0x55cdf86a3c90 {
[1] => "recipe-name.recycling"
[2] => "rocket-silo"
}
[name] => "rocket-silo-recycling"
[ingredients] => table: 0x55cdf86a3c90 {
[1] => table: 0x55cdf86abd30 {
[amount] => 1
[name] => "rocket-silo"
[type] => "item"
}
}
[energy_required] => 1.875
[hidden] => true
}