blazerdrive09 Posted July 4, 2016 Share Posted July 4, 2016 Can someone show me how to properly set up the mod config data and be able to send the settings that you choose to the prefab lua file of the item being added? I know the code such as GetModConfigData(Variablename) that you can use in the modmain lua file but how does one get the settings sent to the prefab lua file. For example, I want to add a tag to the item as it is being created, however, AddPrefabPostInit in the Modmain lua file to add this tag so i want the config data to be sent to the prefab file so that the tag can be added in the prefab file instead which will make it usable by other lua files. This is for the don't Starve Together if the AddPrefabPostInit doesn't work in that as that would explain why the tag isn't getting added when it should in my current code. I want to start off adding the config settings fresh, don't want to fix my old code but if you can give me insight as to why it wasn't working that would be great. ModMain: PrefabFiles = { "compost_box" } Assets = { Asset( "IMAGE", "minimap/composter.tex" ), Asset( "ATLAS", "minimap/composter.xml" ), Asset("IMAGE", "images/inventoryimages/composter.tex"), Asset("ATLAS", "images/inventoryimages/composter.xml"), } AddMinimapAtlas("minimap/composter.xml") local require = GLOBAL.require local Vector3 = GLOBAL.Vector3 local TUNING = GLOBAL.TUNING local IsServer = GLOBAL.TheNet:GetIsServer() local TheInput = GLOBAL.TheInput local ThePlayer = GLOBAL.ThePlayer local net_entity = GLOBAL.net_entity STRINGS = GLOBAL.STRINGS RECIPETABS = GLOBAL.RECIPETABS Recipe = GLOBAL.Recipe Ingredient = GLOBAL.Ingredient TECH = GLOBAL.TECH local decaysinto = GetModConfigData("WHATTODECAYINTO") GLOBAL.STRINGS.NAMES.COMPOSTER = "Composter" STRINGS.RECIPE_DESC.COMPOSTER = "Get that Fertalizer!" GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COMPOSTER = "It smells" local composter = GLOBAL.Recipe("composter",{ Ingredient("cutgrass", 6), Ingredient("poop", 2), Ingredient("log", 2) }, RECIPETABS.FARM, TECH.SCIENCE_ONE, "composter_placer" ) composter.atlas = "images/inventoryimages/composter.xml" local function ComposterPost(inst) if GetModConfigData("WHATTODECAYINTO") == 1 then inst:AddTag("guano") else if GetModConfigData("WHATTODECAYINTO") == 2 then inst:AddTag("rot") end end end AddPrefabPostInit("compost_box", ComposterPost) ModInfo: name = "A composter" description = "Let the fertalizer roll in!" author = "Blazerdrive09 and Jd5team" version = "1.0" forumthread = "" api_version = 6 dst_compatible = true dont_starve_compatible = false reign_of_giants_compatible = false all_clients_require_mod = true icon_atlas = "composter.xml" icon = "composter.tex" configuration_options = { { name = "WHATTODECAYINTO", label = "Decays Into", hover = "Whether food in the composter turns into guano or rot", options = { {description = "Guano", data = 1}, {description = "Rot", data = 2}, }, default = 1, } } Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/ Share on other sites More sharing options...
Mobbstar Posted July 4, 2016 Share Posted July 4, 2016 perhaps you should call "GetModConfigData" outside of the postinit fn and save the result in a variable Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/#findComment-789832 Share on other sites More sharing options...
blazerdrive09 Posted July 4, 2016 Author Share Posted July 4, 2016 I tried that earlier with the local decaysinto = GetModConfigData("WHATTODECAYINTO") that I left then switched the GetMOdConfigData in hte postint fn with the decaysinto variable. It didn't work or should I not be making the decaysinto variable a local variable? Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/#findComment-789892 Share on other sites More sharing options...
DarkXero Posted July 6, 2016 Share Posted July 6, 2016 I switched the AddTags for print(1) and print(2) and it worked properly. This should be working. How do you know the tags aren't there? Is there a mod I can check? Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/#findComment-790227 Share on other sites More sharing options...
blazerdrive09 Posted July 6, 2016 Author Share Posted July 6, 2016 (edited) What do u mean print(1) and print(2)? As for how I know the tags aren't there, when i was testing it multiple times with different values for the data and other ways, The default being set to guano in all cases, it would always produce rot even if the default was guano and even if i went into the config options and made sure it was set to guano. I even removed the rot section: On 7/3/2016 at 11:29 PM, blazerdrive09 said: else if GetModConfigData("WHATTODECAYINTO") == 2 then inst:AddTag("rot") end so that there it would only check if guano was selected or not and wouldn't ever run the addTag("rot") (which i never use in the file that checks if it needs to produce guano or rot anyway) and it would produce rot still (as rot is defaulted unless the tag guano exists). As for Mod you can check, right now the version without config settings at all is uploaded to the steam workshop which I can link and it produces guano for all items put into the composter besides eggs. What I did to try to get the config settings right was add the settings to the modinfo, add the addprefabpostint to the modmain as seen above, then I added a section Owner:HasTag("guano") to the if statement in the perishable file (similar to how it checks if the container is an icebox or something else) where it turns a perishable item into rot so that i can check whether it has to turn into guano instead. Steam link: http://steamcommunity.com/sharedfiles/filedetails/?id=717667020 Edited July 6, 2016 by blazerdrive09 Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/#findComment-790421 Share on other sites More sharing options...
blazerdrive09 Posted July 6, 2016 Author Share Posted July 6, 2016 I figured it out through another method, I added a Global Tuning value in which I stored the modconfig data then in the prefab of the file, I called upon the tuning data and used an if statement to add the tags needed depending on the data and it worked. Thanks for all the help anyway guys, dont know why the original way i was trying to do it wasn't working. Link to comment https://forums.kleientertainment.com/forums/topic/68632-help-setting-up-mod-config-settings-and-getting-the-prefab-of-the-item-being-added-the-data/#findComment-790505 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