Skip to content

Game would not Load after updates on github #6

@skynyrd47

Description

@skynyrd47

Ran into an issue with:
Error: Running LUA method 'update'.
C:/Users/brown/Documents/My Games/FarmingSimulator2025/mods/FS25_ContractorMod/scripts/ContractorModWorker.lua:28:
attempt to index nil with 'playerGraphics'

ended up using Claude and got everything back up and running, it updated 3 luas.

Perfect! Now I can see the issue. Line 36 in main.lua is actually this line:
luacontractormod = ContractorMod:new(mission, g_i18n, g_inputBinding, g_gui, g_soundManager, modDirectory, modName)
The error attempt to index nil with 'new' means ContractorMod is nil. This happens because ContractorMod.lua failed to load properly due to our earlier errors!
The Cascade Effect
Here's what's happening:

main.lua loads at line 14: source("scripts/ContractorMod.lua")
ContractorMod.lua tries to run but hits an error during initialization
Because it errored, the ContractorMod class never gets defined
When main.lua tries to create ContractorMod:new() at line 36, it fails because ContractorMod is nil

The Solution
We need to add error protection in main.lua to handle when ContractorMod fails to load:Creating fixed main.lua with error handling for when ContractorMod class fails to loadCreating fixed main.lua with error handling for when ContractorMod class fails to loadmain.luaDoneNow let me also check if there's an issue in the ContractorMod.lua initialization. Let me look at the part that's likely failing:Looking at the ContractorMod initialization section around line 156Looking at the ContractorMod initialization section around line 156DoneI see another bug! Line 168 references rot but it was never defined. Let me fix that:Fixing undefined 'rot' variable - should be 'yaw'Fixing undefined 'rot' variable - should be 'yaw'ContractorMod.lua+11-8DoneNow copy all three fixed files to outputs:Ran a command, read a fileCopying all three fixed files to outputsScriptPresented 3 filesDoneComplete Fix - All Three Files!
I've fixed all the errors across three files. Here's what was wrong and what I fixed:

  1. ContractorModWorker.lua
    Errors Fixed:

Line 28: self.npc.playerGraphics was nil
Line 35: self.npc itself was nil
Multiple other self.npc references

Solution: Wrapped all NPC access in comprehensive nil checks with fallbacks

  1. ContractorMod.lua
    Errors Fixed:

Line 156: PlayerStyle.new() failed because PlayerStyle was nil
Line 168: Undefined variable rot caused crash
Missing nil check on posVector

Solutions:

Added PlayerStyle nil check with fallback to g_helperManager:getRandomHelperStyle()
Removed the broken rot line
Added nil check before accessing posVector

  1. main.lua (NEW)
    Error Fixed:

Line 36: ContractorMod class was nil because previous files failed to load

Solution: Added nil check to prevent cascade failure and provide clear error message

Installation Instructions
Replace these three files in:
C:\Users\brown\Documents\My Games\FarmingSimulator2025\mods\FS25_ContractorMod\scripts
Files to replace:

ContractorModWorker.lua
ContractorMod.lua
main.lua

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions