Page 1 of 1

Edit an existing mod

Posted: Wed Apr 03, 2024 4:29 pm
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?

Re: Edit an existing mod

Posted: Wed Apr 03, 2024 4:39 pm
by Koub
[Koub] Moved to Modding help

Re: Edit an existing mod

Posted: Wed Apr 03, 2024 5:10 pm
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.

Re: Edit an existing mod

Posted: Wed Apr 03, 2024 5:28 pm
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.

Re: Edit an existing mod

Posted: Wed Apr 03, 2024 5:39 pm
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.

Re: Edit an existing mod

Posted: Wed Apr 03, 2024 8:41 pm
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.

Re: Edit an existing mod

Posted: Thu Apr 04, 2024 10:13 am
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.

Re: Edit an existing mod

Posted: Thu Apr 04, 2024 6:55 pm
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

Re: Edit an existing mod

Posted: Thu Apr 04, 2024 11:53 pm
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.

Re: Edit an existing mod

Posted: Fri Apr 05, 2024 5:04 am
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) :)