Basic mod template

Place to post guides, observations, things related to modding that are not mods themselves.
neoChaos12
Inserter
Inserter
Posts: 36
Joined: Fri Jan 03, 2025 8:43 am
Contact:

Basic mod template

Post by neoChaos12 »

@admin I'm a dum-dum and didn't post this in the modding discussion section. Could you kindly move this there?

Hello dear modders! I was browsing through the ideas and suggestions forum today and saw a whole bunch of suggestions that looked sensible and minor enough to be bundled into my own personal tweaks mod (I'm a python programmer by profession, with 0 experience in lua and graphics design). This got me wondering - are there any templates for basic mods in existence that a new modder could potentially just fork in order to
1. quickly dip their toes in the factorio modding pool
2. rapidly test quick and easy ideas

Any suggestions? Alternatively, maybe someone could suggest good starting points? I'd imagine one would need to start by defining what a sensible categorization for possible mod functionalities would be before defining a template for it. If any experienced modders see this post, your input would be very appreciated!
Last edited by neoChaos12 on Thu Jan 16, 2025 12:37 am, edited 2 times in total.
eugenekay
Filter Inserter
Filter Inserter
Posts: 749
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Basic mod template

Post by eugenekay »

There are a couple on Github / Factorio Mod portal that I have encountered. fgardt/factorio-mod-template seems to be the most complete & up-to-date.

Good Luck!
neoChaos12
Inserter
Inserter
Posts: 36
Joined: Fri Jan 03, 2025 8:43 am
Contact:

Re: Basic mod template

Post by neoChaos12 »

eugenekay wrote: Wed Jan 15, 2025 5:15 pm There are a couple on Github / Factorio Mod portal that I have encountered. fgardt/factorio-mod-template seems to be the most complete & up-to-date.

Good Luck!
This looks quite interesting. Thanks!
Although on close examination, it seems like less of a template and more of an automation wrapper to handle a bunch of publication tasks. Would you also happen to have some recommendations for simple mods I could look at as code examples? I imagine diving straight into a massive overhaul is definitely not the way to begin. ;)
dmikalova
Inserter
Inserter
Posts: 21
Joined: Thu Nov 26, 2020 7:48 am
Contact:

Re: Basic mod template

Post by dmikalova »

The wiki has a section on making mods including a full walkthrough on a basic mod.

https://wiki.factorio.com/Tutorial:Modding_tutorial
eugenekay
Filter Inserter
Filter Inserter
Posts: 749
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Basic mod template

Post by eugenekay »

neoChaos12 wrote: Thu Jan 16, 2025 12:19 am This looks quite interesting. Thanks!
Although on close examination, it seems like less of a template and more of an automation wrapper to handle a bunch of publication tasks. Would you also happen to have some recommendations for simple mods I could look at as code examples? I imagine diving straight into a massive overhaul is definitely not the way to begin. ;)
D’oh, I didn’t realize GitHub doesn’t show the “downstream” Repositories which use this Template under the Forks page. Here is one that adds Pipes capable of holding Plasma from fusion reactors, for example: OGorbitz/plasma-duct.
neoChaos12
Inserter
Inserter
Posts: 36
Joined: Fri Jan 03, 2025 8:43 am
Contact:

Re: Basic mod template

Post by neoChaos12 »

eugenekay wrote: Thu Jan 16, 2025 1:00 am
D’oh, I didn’t realize GitHub doesn’t show the “downstream” Repositories which use this Template under the Forks page. Here is one that adds Pipes capable of holding Plasma from fusion reactors, for example: OGorbitz/plasma-duct.
Yeah, I was quite baffled to see just a handful of forks, though looking through the profiles of people who starred that repo was quite fruitful too. Thanks for the recommendation!
dmikalova wrote: Thu Jan 16, 2025 12:49 am The wiki has a section on making mods including a full walkthrough on a basic mod.

https://wiki.factorio.com/Tutorial:Modding_tutorial
Haaaa... yeah, the wiki. To be honest, I found it a tad too intimidating. It's very detailed, well-structured and likely very useful. I just wanted to instead boot up a small script and Jack Sparrow my way through, since I'm doing this for fun rather than my job, for a change. Hopefully that's fair game. :-?
volaticus
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Nov 28, 2024 3:05 am
Contact:

Re: Basic mod template

Post by volaticus »

As a brand new Factorio modder, I had the same question as OP. I'm trying to approach this from both sides: I found an existing mod that leverages the functionality that I want to leverage, which makes for a great endpoint, but I wanted something more helpful as a starting point than what's linked above. Since this thread was the first discussion I found on the topic, I thought I'd come back with what I found after searching further, in case it helps OP or anyone else who stumbles through here.

The starting point that I was looking for, boilerplate, is described (but not provided directly) in the Mod Structure article in the API Docs' auxiliary section. This article is linked from both the API Docs home page and the Tutorial:Modding_tutorial page on the wiki. It's an invaluable resource: it contains the syntax for the only mandatory file, info.json, and a description of each of the properties you can define in it, as well as all of the optional files and folders, and links to the documentation on them. Gangsir's tutorial touches on some of these files, but doesn't go into detail about everything you can do with them, so I recommend the Mod Structure article as a supplement.

Anyway, I didn't feel like making the folders and files from scratch, so I was looking for boilerplate so I could just dive into each file right away. However, as it turns out there's only one mandatory file, the most basic boilerplate isn't super useful - one would save more time using a more fully-featured boilerplate, but a brand new modder may need additional context to benefit from such. Unfortunately, all of the resources I could find are from before version 2.0, so I can't vouch for their compatibility, but these in particular seem potentially useful for simply visualizing what the structure might look like in practice, if nothing else:
  1. https://github.com/swzrdlrd/factorio-mod-template
  2. https://github.com/ZwerOxotnik/factorio-example-mod via https://mods.factorio.com/mod/example-mod
Repo 1 is almost as barebones as it gets. Repo 2 has many optional folders and files, as well as some meta-elements, such as for publishing, but it's much older, and so is more likely to be incompatible somehow. Regardless, comparing these two repos while reading the Mod Structure page was very useful for getting off the ground, even without being able to fork, because between all three pages is the full context that I needed to help me understand how to tweak the existing mod into what I want, and what external tools I might employ if I wanted to develop with long-term support in mind.

From there, the Data Lifecycle article should probably be your next resource - it explains how the game uses the files you just learned about and where your code fits into the equation, with handy links to relevant wiki pages and API documentation. After absorbing all of these pages, Gangsir's tutorial was much easier for me to follow.
Post Reply

Return to “Modding discussion”