JamesWilko / Payday-2-BLT-Lua

Mods folder that controls the ingame aspects of the Payday 2 BLT.
MIT License
16 stars 26 forks source link

"mods/base/lua/MenuManager.lua:155: table index is nil" crash when accessing Options » Lua Mods after reinstalling previously removed mod #13

Closed AmperAndSand closed 7 years ago

AmperAndSand commented 7 years ago

I have recently installed a mod (put its folder in the '\PAYDAY 2\mods' directory) after previously disabling it, and then removing it from the 'mods' folder afterwards (prior to version r14).

After I've installed the mod, when I go to Options » Lua Mods, the game crashes with crash.txt log:

Application has crashed: C++ exception
mods/base/lua/MenuManager.lua:155: table index is nil

I've looked at that file, and it's this part of function ModMenuCreator.create_lua_mods_menu:

if not _hooks[ hook ] then
    hooks_str = hooks_str .. "    " .. tostring(hook) .. "\n"
    _hooks[ hook ] = true
end

It crashes in the _hooks[ hook ] = true line. I fixed it by modifying the code above to:

if hook and not _hooks[ hook ] then -- added check for 'hook' variable
    hooks_str = hooks_str .. "    " .. tostring(hook) .. "\n"
    _hooks[ hook ] = true
end

... which allowed me to access Options » Lua Mods without crashing.

AmperAndSand commented 7 years ago

It seems that this has been fixed as per https://github.com/JamesWilko/Payday-2-BLT-Lua/commit/f04c3bac71806bf7c1d8801cab541e17c05cd7fe