Cyde042 Posted October 19, 2016 Share Posted October 19, 2016 I want to dynamically fill the configuration option table based on my own criteria, so I want to get access to prefab0002 (prefab list for Shipwrecked). But the thing is, I can't even index Global... Any ideas? Here's the relevant part. Spoiler configuration_options = {} for k,v in pairs(GLOBAL.package.loaded.prefab0002) do --says can't index GLOBAL, but without it, it says "requires Global to index Package" if v.components.inventoryitem then table.insert(configuration_options, 1) print("Adding " .. v) end end Also, how the hell do I add a nested list with a function to a list? Spoiler configuration_options = {} for k,v in pairs(GLOBAL.package.loaded.prefab0002) do if v.components.inventoryitem then table.insert(configuration_options, { name = v, label = GLOBAL.STRINGS.NAMES.PREFAB, options = stackSize, default = function(v) if v.components.stackable then return v.components.stackable.maxsize else return 1 end, --it doesn't like the function for some reason, says unexpected symbol near ',' }) print("Adding " .. v) end end Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/ Share on other sites More sharing options...
Mobbstar Posted October 19, 2016 Share Posted October 19, 2016 (edited) modinfo.lua has basically no access to the global environment or any of its variables and functions. You can access your mod's modinfo from modmain (just use MODCONFIG), though there's a comment warning about modifying it in-game, so it might not work entirely. Edited October 19, 2016 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827052 Share on other sites More sharing options...
Cyde042 Posted October 19, 2016 Author Share Posted October 19, 2016 20 minutes ago, Mobbstar said: modinfo.lua has basically no access to the global environment or any of its variables and functions. You can access your mod's modinfo from modmain (just use MODCONFIG), though there's a comment warning about modifying it in-game, so it might not work entirely. You mean GetModConfigData? But then the issue is that it will need a prebuilt configuration_options table. What I want to do is create a dynamic one, that builds itself from another table. Would it be possible to access a file in the mod folder maybe? Then I would simply need to copy-paste the list in my mod directory. Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827055 Share on other sites More sharing options...
Cyde042 Posted October 19, 2016 Author Share Posted October 19, 2016 Ehh, I feel stupid now. There's an easier workaround. I could simply make modmain check the prefabs and add them to to a file, then I simply copy paste them into modinfo... Welp. Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827059 Share on other sites More sharing options...
Mobbstar Posted October 19, 2016 Share Posted October 19, 2016 55 minutes ago, Cyde042 said: What I want to do is create a dynamic one, that builds itself from another table. Would it be possible to access a file in the mod folder maybe? Then I would simply need to copy-paste the list in my mod directory. MODCONFIG is the configuration_options table's name in modmain.lua: table.insert(MODCONFIG, {name = "sample option"}) Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827075 Share on other sites More sharing options...
Cyde042 Posted October 20, 2016 Author Share Posted October 20, 2016 17 hours ago, Mobbstar said: MODCONFIG is the configuration_options table's name in modmain.lua: table.insert(MODCONFIG, {name = "sample option"}) Doesn't work. For some reason, I can't access the components of the prefab list. Would you know what to do about that? Spoiler for k,v in pairs(GLOBAL.PREFABFILES) do if v.components then --says "can't index" if v.components.inventoryitem and not v.components.tool and not v == "heatrock" then table.insert(MODCONFIG, { name = v, label = GLOBAL.STRINGSS.PREFAB, options = stackSize, default = function(v) if v.components.stackable then return v.components.stackable.maxsize else return 1 end end, }) print(v) end end end Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827392 Share on other sites More sharing options...
Mobbstar Posted October 20, 2016 Share Posted October 20, 2016 3 hours ago, Cyde042 said: For some reason, I can't access the components of the prefab list. Would you know what to do about that? Those are just the file names, they're loaded after modmain... Link to comment https://forums.kleientertainment.com/forums/topic/70972-is-it-possible-to-get-access-to-game-files-from-modinfo/#findComment-827437 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