Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error on MenuBuilder:load_settings() #23

Closed
Riki9811 opened this issue Aug 31, 2023 · 3 comments
Closed

Fatal error on MenuBuilder:load_settings() #23

Riki9811 opened this issue Aug 31, 2023 · 3 comments

Comments

@Riki9811
Copy link

I've been having issues using 'MenuBuilder.lua'. The script works fine if there is no settings file in 'PAYDAY 2\mods\saves'. But if that file exists when I open the game my TestMod won't load in correctly and there is no settings menu under the in-game mod options.

Reading the logs at 'PAYDAY 2\mods\logs' I get this error:

12:07:20 AM FATAL ERROR:  (C:\projects\payday2-superblt\src\InitiateState.cpp:320) mods/TestMod/MenuBuilder.lua:31: attempt to call field 'replace' (a nil value)
stack traceback:
	mods/TestMod/MenuBuilder.lua:31: in function 'load_settings'
	mods/TestMod/MenuBuilder.lua:13: in function 'init'
	[string "core/lib/utils/coreclass.lua"]:35: in function 'new'
	mods/TestMod/main.lua:9: in main chunk
	[C]: in function 'dofile'
	mods/base/base.lua:169: in function 'run_hook_file_orig'
	mods/The Fixes Preventer/coresystem.lua:145: in function 'RunHookFile'
	mods/base/base.lua:157: in function 'RunHookTable'
	mods/base/base.lua:189: in function 'OrigRequire'
	mods/BeardLib/Core.lua:406: in function 'require'
	[string "lib/setups/setup.lua"]:72: in main chunk
	...
	mods/BeardLib/Core.lua:406: in function 'require'
	[string "lib/setups/menusetup.lua"]:1: in main chunk
	[C]: in function 'require'
	mods/base/base.lua:188: in function 'OrigRequire'
	mods/BeardLib/Core.lua:406: in function 'require'
	[string "lib/entry.lua"]:13: in main chunk
	[C]: in function 'require'
	mods/base/base.lua:188: in function 'OrigRequire'
	mods/BeardLib/Core.lua:406: in function 'require'
	[string "core/lib/coreentry.lua"]:19: in main chunk

If I understand the logs correctly the problem is on this line:

table.replace(self._table, data, true)

because the function table.replace() does not exist.


I've searched on the Lua Reference Manual and under Table Manipulation I see there is no mention about a table.replace() function. Could this be an old and deprecated function that no longer works?

Furthermore, the manual does not have a table.union() function, so maybe there is also a problem on line 90:

local params = self._params[k] and table.union(clone(inherited_params), self._params[k]) or inherited_params

I'm completely new to both modding and the Lua language and I don't really know what I'm doing. I don't even know if looking up the functions in the online manual was the correct move or if that has nothing to do with the error I'm having.

This problem could very well be caused by an error on my part and in that case I'm sorry to bother, but I'd like to understand what I'm doing wrong.

@segabl
Copy link
Owner

segabl commented Sep 1, 2023

When you use the MenuBuilder provided as part of HopLib, it is expected to actually have HopLib in the mods folder. Judging by your report, you copied the menu builder to your testmod to use from there?
In that case you are getting these errors cause the MenuBuilder relies on some provided functionality of HopLib (the table functions that you tried to find)

@Riki9811
Copy link
Author

Riki9811 commented Sep 1, 2023

Judging by your report, you copied the menu builder to your testmod to use from there?

Yup that's exactly what I did, I thought each file was a stand-alone library. Now I've installed HopLib as a separate mod, and included this inside my mod.txt:

"dependencies" : {
    "pd2-hoplib" : { "meta" : "https://updates.hoppip.at/pd2-hoplib" }
},

I copied this lines from another mod of yours that uses HopLib (I should have checked how your mods use HopLib in the first place). I guess this is the correct way to go about it cause now everything works fine.

Thanks for your help!

@Riki9811 Riki9811 closed this as completed Sep 1, 2023
@segabl
Copy link
Owner

segabl commented Sep 3, 2023

Yes, this is how you are supposed to use it, glad you could sort it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants