Learning to mod
-
- Manual Inserter
- Posts: 2
- Joined: Sat Aug 23, 2025 7:24 pm
- Contact:
Learning to mod
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
Re: Learning to mod
Filter Mining Drills is a good example of a "minimal mod" - it consists of only four files:
...and that's it! Good Luck!
- info.json contains metadata about the Mod
- README.md explains the mod in plain text
- thumbnail.png is a visual aid
- data-updates.lua is the actual "working content" of the Mod
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
Re: Learning to mod
This might help too https://wiki.factorio.com/Tutorial:Modd ... ctorio_mod
Wise men speak because they have something to say Fools because they have to say something. (Plato)
-
- Manual Inserter
- Posts: 2
- Joined: Sat Aug 23, 2025 7:24 pm
- Contact:
Re: Learning to mod
im trying to do a recipe change and the code shown does not show an example of what else i need besides this
local multiplier = settings.startup["cheaper-ammo-multiplier"].value
local recipe = data.raw.recipe["firearm_magazine"]
if recipe then
recipe.ingredients = {
{ type = "item", name = "iron_plate", amount = 1 }
{ type = "item", name = "coal", amount = 1 }
}
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
local multiplier = settings.startup["cheaper-ammo-multiplier"].value
local recipe = data.raw.recipe["firearm_magazine"]
if recipe then
recipe.ingredients = {
{ type = "item", name = "iron_plate", amount = 1 }
{ type = "item", name = "coal", amount = 1 }
}
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
Re: Learning to mod
To start out, create a folder in your user data directory/mods folder. This folder must have a specific name, mod name. You don't need to zip anything for now, that will come later when you're done working on the mod. When you're finished, the mod directory should look like this:
(user data directory, sometimes called .factorio)
mods
mod name
Then, inside fire-armor, create two files, info.json and data.lua. The directory should now look like:
(user data directory, sometimes called .factorio)
mods
mod name
for your code you need additional file settings.lua
--in settings.lua:
--in data.lua:
your code
(user data directory, sometimes called .factorio)
mods
mod name
Then, inside fire-armor, create two files, info.json and data.lua. The directory should now look like:
(user data directory, sometimes called .factorio)
mods
mod name
- data.lua
- info.json
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"
}
--in settings.lua:
Code: Select all
data:extend({
{
type = "int-setting",
name = "cheaper-ammo-multiplier",
setting_type = "startup",
minimum_value = 1,
default_value = 1
}
})
your code
Re: Learning to mod
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
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!