kiopho Posted December 12, 2014 Share Posted December 12, 2014 --------------------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 Link to comment Share on other sites More sharing options...
kiopho Posted December 12, 2014 Author Share Posted December 12, 2014 @SethR Please, any help ? Link to comment Share on other sites More sharing options...
simplex Posted December 12, 2014 Share Posted December 12, 2014 @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. Link to comment Share on other sites More sharing options...
kiopho Posted December 12, 2014 Author Share Posted December 12, 2014 @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 Link to comment 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 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 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 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 Share on other sites More sharing options...
Eyres1 Posted March 2, 2015 Share Posted March 2, 2015 Ok sweet thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.