An item that isn't in any loot list exists in the game, but nobody is ever going to find it. To make it show up in fridges, shelves or lockers, you have to add it to the distributions.
How it works
Every type of container on the map (a house fridge, the wine shelf at a liquor store, a locker at a police station) uses a named list inside the ProceduralDistributions.list table. Each list has an items table that alternates item, weight, item, weight...:
ProceduralDistributions.list["FridgeGeneric"].items = {
"Base.Milk", 4,
"Base.Cheese", 3,
...
}The higher the weight, the more often it shows up. That's why you add two values: first the item, then the weight.
The safe pattern (the one all our mods use)
require "Items/ProceduralDistributions"
local aplicado = false
local function agregarLoot()
if aplicado then return end
local ok, err = pcall(function()
local function meter(lista, item, peso)
local dist = ProceduralDistributions.list[lista]
if not dist or not dist.items then return end
table.insert(dist.items, item)
table.insert(dist.items, peso)
end
meter("FridgeGeneric", "Melvin42.MelonConVino", 1.5)
meter("LiquorStoreWine", "Melvin42.MelonConVino", 1.0)
meter("GroceryStandFruits1", "Melvin42.MelonConVino", 0.75)
aplicado = true
end)
if not ok then print("[MiMod] error en el loot: " .. tostring(err)) end
end
Events.OnPostDistributionMerge.Add(agregarLoot)Why each part is there:
- Checking that the list exists (
if not dist ...): list names change between game versions. If a list no longer exists, your mod skips it instead of crashing. pcall: if something fails, the error ends up inconsole.txtwith your mod's prefix, and the game keeps loading.aplicado("applied"): stops the item from being added twice if the event fires more than once.- The file goes in
media/lua/server/Items/.
Finding the list names
You'll find all of them, searchable and with the items in each one, in the loot lists reference. You can also open the game file media/lua/server/Items/ProceduralDistributions.lua (in the install folder) and search for keywords: Fridge, Kitchen, Liquor, Gun, Police, Clothing, Shoe... Some of the names we've used in published mods:
| Where | Lists |
|---|---|
| Fridges | FridgeGeneric, FridgeTrailerPark, FridgeBreakRoom, FridgeRich, FridgeBeer |
| Wine and liquor stores | LiquorStoreWine, StoreShelfWine, CrateWine, KitchenBottles |
| Produce stands | GroceryStandFruits1, GroceryStandFruits2, ProduceStorageWatermelons |
| Unusual stuff | JewelryGems, LaboratoryLockers, ArmyBunkerLockers |
How much weight to use
There's no exact formula, because it depends on how many other items are in that list. A practical guide:
- 0.03 to 0.1: very rare, almost a prize (the complete lightsaber).
- 0.5 to 1: found every now and then.
- 2 to 4: common in that type of container.
A trick from Sable de Luz: the parts show up more often (weight 0.3 to 0.6) and the complete item is super rare (0.05). That way the player can either build it or get lucky.