kiopho Posted December 12, 2014 Share Posted December 12, 2014 (edited) --------------------SOLVED-------------------- Hi there ! So I'm trying to do just that with RPG HUD, but from scripts/widgets/badges.lua I found this in the patch notes for RoG : "Made it easier to call GetModConfigData from non-main mod files (use ModIndex:GetModActualName(fancyname) function [fancyname is name string from modinfo] as second parameter to a GetModConfigData(optionname, modname) function call)." The name in modinfo.lua is "RPG HUD" and the option I'm looking for is "Custom_Badges". So am I supposed to do it like this ? :local custom_badges_yes = (GetModConfigData("Custom_Badges", ModIndex:GetModActualName("RPG HUD"))=="yes")Cause it crashes saying this :...eamapps/common/dont_starve/data/scripts/modindex.lua:279: attempt to index field 'savedata' (a nil value)LUA ERROR stack traceback: C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(279,1) in function 'GetModActualName' C:/Jeux/Steam/steamapps/common/dont_starve/data/../mods/RPG HUD Neat/scripts/widgets/badge.lua(104,1) in main chunk =[C] in function 'require' C:/Jeux/Steam/steamapps/common/dont_starve/data/../mods/RPG HUD Neat/modmain.lua(714,1) in main chunk =[C] in function 'xpcall' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/util.lua(439,1) in function 'RunInEnvironment' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(190,1) in function 'InitializeModMain' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(171,1) in function 'LoadMods' scripts/main.lua(229,1) in function 'ModSafeStartup' scripts/main.lua(274,1) =[C] in function 'SetPersistentString' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(18,1) in function 'SavePersistentString' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(76,1) =[C] in function 'GetPersistentString' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(63,1) in function 'BeginStartupSequence' scripts/main.lua(273,1) in function 'callback' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(322,1) =[C] in function 'GetPersistentString' C:/Jeux/Steam/steamapps/common/dont_starve/data/scripts/modindex.lua(302,1) in function 'Load' scripts/main.lua(272,1) in main chunk Edited December 12, 2014 by kiopho Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/ Share on other sites More sharing options...
kiopho Posted December 12, 2014 Author Share Posted December 12, 2014 (edited) @SethR Please, any help ? Edited December 12, 2014 by kiopho Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-583915 Share on other sites More sharing options...
simplex Posted December 12, 2014 Share Posted December 12, 2014 (edited) @kiophoThat function is misdocumented. The second argument should not be the mod's "fancy name" (the "name" field in modinfo.lua), it should be the name of the mod's folder (the value of the "modname" variable set automatically in modmain.lua). But, of course, passing the name of the mod folder is somewhat tricky for Workshop mods, since it's not quite predictable (being "workshop-SOMENUMBER").I suggest that, instead, you export the mod environment. Put this in modmain.lua:GLOBAL.package.loaded["rpghud.modenv"] = envAnd then, in widgets/badges.lua (or anywhere else), dolocal modenv = require "rpghud.modenv"local custom_badges_yes = modenv.GetModConfigData("Custom_Badges")You can also access any variable from the mod environment via this "modenv" above. Just keep in mind that you can't add new postinits after modmain.lua has finished, so even though you could call things like "modenv.AddSimPostInit()", this will have no effect. Edited December 12, 2014 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-583928 Share on other sites More sharing options...
kiopho Posted December 12, 2014 Author Share Posted December 12, 2014 (edited) @simplex, Thanks for your answer man ! I finally got it to work using thiscustom_badges_yes = (GetModConfigData("Custom_Badges", KnownModIndex:GetModActualName("RPG HUD"))=="yes")So yeah, KnownModIndex:GetModActualName instead of ModIndex:GetModActualName But it seems not to be working like it should. I'll try your solution Edited December 12, 2014 by kiopho 1 Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-583932 Share on other sites More sharing options...
kiopho Posted December 12, 2014 Author Share Posted December 12, 2014 @simplex Thanks a lot man, your solution works just fine I owe you big time Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-583942 Share on other sites More sharing options...
Eyres1 Posted March 2, 2015 Share Posted March 2, 2015 I've read through this and I'm having a similar problem, but not quite. I have several configuration options and would like to use them inside of [modname]\scripts\prefabs\[prefab].lua but I can no longer just use: [codesyntax]local infinite = (GetModConfigData("stack_size")=="infinite")[/codesyntax] and then [codesyntax]inst:AddComponent("stackable")if ten theninst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEMelseif twenty theninst.components.stackable.maxsize = TUNING.STACK_SIZE_MEDITEMelseif forty theninst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEMelseif infinite theninst.components.stackable.maxsize = 1000end[/codesyntax] Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-618492 Share on other sites More sharing options...
Eyres1 Posted March 2, 2015 Share Posted March 2, 2015 Wow that looks terrible, I hope you understand, I'm new to this site :/ Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-618493 Share on other sites More sharing options...
seronis Posted March 2, 2015 Share Posted March 2, 2015 Wow that looks terrible, I hope you understand, I'm new to this site :/local foldername = KnownModIndex:GetModActualName("ModsName")inst.someVar = GetModConfigData("op_foobar", foldername)Yup understood i think. When outside of modmain you have to specify which mod the option belongs to. This modname is actually not the modname as it shows up in modinfo but the name of the FOLDER it is in. Yeah weird design decision but you can get the foldername with the line i used above. The "ModsName" actually is how the mod name appears in modinfo.lua Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-618522 Share on other sites More sharing options...
Eyres1 Posted March 2, 2015 Share Posted March 2, 2015 Ok sweet thanks! Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-618541 Share on other sites More sharing options...
Adgycarp Posted December 17, 2025 Share Posted December 17, 2025 11 years later, this is still relevant. Thank you. 1 Link to comment https://forums.kleientertainment.com/forums/topic/46095-using-getmodconfigdata-outside-of-modmain/#findComment-1845942 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now