Upgradeable Factories Fix for Farming Simulator 22
Upgradeable Factories Fix for Farming Simulator 22
I currently have 3,353 hours logged in Farming Simulator 22. I've been gun shy about dropping $50 on the newest version, but I’ll probably make the leap sometime this year. Until then, I’m still having a blast chugging away on FS22. I run a ton of mods, but one in particular likes to randomly crash my game: Upgradeable Factories. If you play on a large scale, it's almost a necessity. Unfortunately, it comes with a nasty bug that sometimes throws this error:
C:/Users/<YOURUSERNAME>/Documents/My Games/FarmingSimulator2022/mods/FS22_UpgradableFactories/InGameMenuUpgradableFactories.lua:58: attempt to index local 'prodpoint' (a nil value)
Today, after losing two hours of progress from simply opening a factory interface, I decided I’d finally fix it. I know what you're thinking: "Dude, you're not smart enough to fix a mod." And you'd be right. But ChatGPT is.
I unzipped the mod, pasted the contents of InGameMenuUpgradableFactories.lua
into ChatGPT, and asked it to fix the nil value problem. The culprit was this line:
local _, prodpoint = self.pageProduction:getSelectedProduction()
Turns out, if you delete a factory anywhere else on the map, this can return nil and crash the game instantly. But that’s not the only trigger.
After doing some digging, I found that I’m not alone. Other players have reported the same crash, especially after game patches like 1.11 and 1.13.1. Even just opening the production menu can throw this exact error if the mod isn’t catching missing or invalid production points. It’s not tied to one specific action — it’s just a lack of proper error handling in the original code.
So I took it further. I pasted the entire contents of all three mod files into ChatGPT and asked it to comb through the logic for anything else that could cause issues.
The result? Cleaner, safer, more robust code. The AI tightened it up nicely. I zipped the fixed version back into my mods folder and then spent two hours trying to break it again by setting up and deleting factories repeatedly.
Summary?
The mod finally seems to be stable. I don’t know if it’s officially abandoned or if the original author (Az#4971) is even aware of the bug. I’ve run into it many times over the past two years. I always assumed it would eventually be patched, but it never was. I checked the GitHub repo, and there hasn’t been a commit in three years. I’d say there’s no rush from the original dev to fix this crash.
If you’re reading this, I’m guessing you’ve run into the same problem. I’ve uploaded the patched version for you to download — just delete the old FS22_UpgradableFactories
folder from your mods directory and drop this one in.
Hopefully this helps someone still going strong on FS22. And if Az#4971 ever comes back and releases an official fix, let me know — I’ll gladly take this download down and link to the proper version.
Until then: happy farming, and may your factories never crash again.