Learning to mod
Posted: Sat Aug 23, 2025 7:27 pm
im trying to change a recipe in the base game, the basic firearm magazine ( yellow ammo ) im struggling to understand what files i actually need to make this mod work, please help
Code: Select all
local blacklist = { -- Allows for some Drills to be excluded in the future; currently unused/empty list
}
for _, prototype in pairs(data.raw["mining-drill"]) do -- Loop through all "mining-drill" that are already defined
if not blacklist[prototype.name] then -- Check the blacklist to see if it should be skipped
if not prototype.filter_count then -- Mods can specify filter_count and this mod won't override it
prototype.filter_count = 5 -- Modify the "filter_count" property
end
end
end
Code: Select all
{
"name": "mod name",
"version": "0.1.0",
"title": "Mod Name",
"author": "You",
"factorio_version": "2.0",
"dependencies": ["base >= 2.0"],
"description": "This mod changes something"
}
Code: Select all
data:extend({
{
type = "int-setting",
name = "cheaper-ammo-multiplier",
setting_type = "startup",
minimum_value = 1,
default_value = 1
}
})
You shouldn't assume that recipe.result_count or r.amount are set to 1, other mods may have changed that! Instead, use the multiplier as multipier:Jakademous wrote: Sun Aug 24, 2025 2:42 pmCode: Select all
if recipe.result then recipe.result_count = multiplier elseif recipe.results then for _, r in pairs(recipe.results) do if r.name == "firearm_magazine" then r.amount = multiplier end end end end
Code: Select all
if recipe.result then
recipe.result_count = recipe.result_count * multiplier
elseif recipe.results then
for _, r in pairs(recipe.results) do
if r.name == "firearm_magazine" then
r.amount = r.amount * multiplier
end
end
end
end