Edit an existing mod

Place to get help with not working mods / modding interface.
Post Reply
Ralph_hh
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Apr 03, 2024 4:18 pm
Contact:

Edit an existing mod

Post by Ralph_hh »

Hello there

To gather some knowlede and experience, I played aroud with some of the games .lua files and tried the same with a mod. With the game that works fine, though it might not be wise, as it might compromise later updates. Anyway, I made a backup..
So, I tried to edit a numer inside a mod. Did not work. Why?
I located the mod files in /appdata/roaming/factorio/mods/
Cloesd the game, then I unzipped one mod (the original zip stays as is). I did a change to a lua file, renamed the folder to modX, renamed the name in the info.json file and zipped it as modX.zip. - The game would not find it when starting.

Attemt 2: copied the original and renamed it originalCOPY - the game then complained that it cannot read originalCOPY. (and ignored my modx that now had the name of the original).

Moved the origianl to another local folder, copied it and modified the copy, the game would not find it...
Anything I zip is invisible for the game.

What is necessary for the game to recognize a new mod zip in that folder?

Koub
Global Moderator
Global Moderator
Posts: 7217
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Edit an existing mod

Post by Koub »

[Koub] Moved to Modding help
Koub - Please consider English is not my native language.

Tertius
Filter Inserter
Filter Inserter
Posts: 683
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Edit an existing mod

Post by Tertius »

Save the original zip of that mod to some directory outside of Factorio.
Uninstall the mod from Factorio. Its zip should now be gone from the Factorio mods directory. You do this to avoid any conflict between the original mod managed by the mod portal and your modifications of that mod.

Unzip the saved zip into the mods directory of Factorio with keeping the subdirectories. You should now have a directory within the Factorio mods directory with the mod's files. This is the place where you can start editing that mod.

Start Factorio. In its mod manager, you will find the mod as installed (since you manually unzipped it into the mods directory) but not activated mod (since you uninstalled it before). So activate it. Factorio will restart and the mod is active.

If you made any edits to that mod that requires migrations, increase its version number in the info.json file and restart Factorio. Otherwise the version number is only used to enable Factorio to detect what version to load if there are multiple zip files of the same mod.

If you only made edits to the runtime part (control.lua and includes from that), you just need to load a save to pick up the edits. If you made changes to the mod's configuration, such as settings.lua/data.lua, you need to restart Factorio, because these changes change the state of Factorio itself.

You don't need to create a zip from your mod - it's sufficient it is unzipped in a subdirectory of the mods folder.

Qon
Smart Inserter
Smart Inserter
Posts: 2120
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Edit an existing mod

Post by Qon »

Check the tutorials for the exact format the name of the folder and mod needs as well as other things to load your mod
https://wiki.factorio.com/Tutorial:Modding_tutorial
https://wiki.factorio.com/Tutorial:Mod_structure

Pretty simple stuff if you follow it line by line.

Then the link "API docs" at the top of this website will give you everything else that you might need to look up.

Ralph_hh
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Apr 03, 2024 4:18 pm
Contact:

Re: Edit an existing mod

Post by Ralph_hh »

Hm... I keep having the same problem as before.

So I copied that mod to another folder, uninstalled (deleted) it in Factorio, the mod folder then did not contain that mod after that. Closed the game.

I unzipped the copied mod to the factorio mod folder und edited it (file prototypes/shared.lua ). Edited the changelog, gave the info.json a newer version, renamed the parent folder also to that newer version. Left it unzipped.
I kept the required format, I did not change anything except version number, which is consistent between info.json and folder name, checked that 10 times by now.

I opened Factorio and went to the mods in the main menu - the new mod did not show.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1655
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Edit an existing mod

Post by Pi-C »

Ralph_hh wrote:
Wed Apr 03, 2024 5:39 pm

I kept the required format, I did not change anything except version number, which is consistent between info.json and folder name, checked that 10 times by now.

I opened Factorio and went to the mods in the main menu - the new mod did not show.
Check the log file! If you start up Factorio, the log will show the mods (by version number and zipped/folder version) the game is trying to load. There could be an error in info.json preventing the mod to load.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Ralph_hh
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Apr 03, 2024 4:18 pm
Contact:

Re: Edit an existing mod

Post by Ralph_hh »

The log file does not list the modified mod, neither as installed not with an error message. This new folder is just ignored.
This does not make sense to me, even if I unzip and zip that thing without any other changes than a single digit in a lua file, it does not appear in the list anymore.

Qon
Smart Inserter
Smart Inserter
Posts: 2120
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Edit an existing mod

Post by Qon »

Ralph_hh wrote:
Wed Apr 03, 2024 5:39 pm
Hm... I keep having the same problem as before.

So I copied that mod to another folder, uninstalled (deleted) it in Factorio, the mod folder then did not contain that mod after that. Closed the game.

I unzipped the copied mod to the factorio mod folder und edited it (file prototypes/shared.lua ). Edited the changelog, gave the info.json a newer version, renamed the parent folder also to that newer version. Left it unzipped.
I kept the required format, I did not change anything except version number, which is consistent between info.json and folder name, checked that 10 times by now.

I opened Factorio and went to the mods in the main menu - the new mod did not show.
Do one change at a time, and load Factorio after each change.
After unzipping, does the otherwise unchanged mod still load (with original not in the mod folder for this test, but unzipped mods are prioritized over zipped)?
If that version loads, do rename in info.json and directory name and see if it still loads... etc

Tertius
Filter Inserter
Filter Inserter
Posts: 683
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Edit an existing mod

Post by Tertius »

Ralph_hh wrote:
Thu Apr 04, 2024 10:13 am
even if I unzip and zip that thing without any other changes than a single digit in a lua file, it does not appear in the list anymore.
What editor do you use for editing the lua file? Lua files are plain ascii files, encoding utf-8. Don't let your editor write a BOM. Proper editors are for example VSCode and Pspad, or the native "Notepad" app of Windows you use for editing ascii config files.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2583
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Edit an existing mod

Post by FuryoftheStars »

Tertius wrote:
Thu Apr 04, 2024 11:53 pm
Ralph_hh wrote:
Thu Apr 04, 2024 10:13 am
even if I unzip and zip that thing without any other changes than a single digit in a lua file, it does not appear in the list anymore.
What editor do you use for editing the lua file? Lua files are plain ascii files, encoding utf-8. Don't let your editor write a BOM. Proper editors are for example VSCode and Pspad, or the native "Notepad" app of Windows you use for editing ascii config files.
Or Notepad++ (as a "proper" editor) :)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics

Post Reply

Return to “Modding help”