BluesyBuesy Posted June 1, 2016 Share Posted June 1, 2016 I could be wrong, but in the Prefabs table, there doesn't appear to be any tags associated with mods. Is there a clean way to determine if a prefab came from a mod? Link to comment https://forums.kleientertainment.com/forums/topic/67817-is-there-a-way-to-distinguish-mod-prefabs-from-default-prefabs/ Share on other sites More sharing options...
rezecib Posted June 1, 2016 Share Posted June 1, 2016 (edited) @BluesyBuesy Hmm, you might be able to iterate over the modindex for their PrefabFiles tables. Let me see... It looks like GLOBAL.ModManager.loadedprefabs stores a list of (a little bit funky) mod names, which correspond to entries in the Prefabs table that list all the prefabs loaded by that mod in their dependencies. So... for _,funkymodname in pairs(GLOBAL.ModManager.loadedprefabs) do print("\nPrefabs loaded by "..funkymodname..":") for _,prefabname in pairs(GLOBAL.Prefabs[funkymodname].deps) do print(prefabname) end end You also want to make sure that you're running this after all mods you're interested in have loaded, which you can do "softly" by reducing your mod's priority in the modinfo, and you can do harder by running it from a postinit of something that loads after. Edited June 1, 2016 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/67817-is-there-a-way-to-distinguish-mod-prefabs-from-default-prefabs/#findComment-778804 Share on other sites More sharing options...
CarlZalph Posted June 1, 2016 Share Posted June 1, 2016 (edited) @BluesyBuesy @rezecib There's a variable autogenerated in scripts/prefablist.lua called PREFABFILES. This contains all vanilla prefabs which also contains the prefabs of DLCs (mainly used for single player since DST doesn't have DLC yet). The way the table is setup is an ipair setup, unfortunately, so I would make a table and cache the result for quicker lookups: -- Cache local VanillaPrefabs = {} for _, v in pairs(GLOBAL.PREFABFILES) do VanillaPrefabs[v] = true end -- Check local someprefab1 = "waxwell" local someprefab2 = "thisdoesnotexist" print(VanillaPrefabs[someprefab1] or "someprefab1 does not exist") print(VanillaPrefabs[someprefab2] or "someprefab2 does not exist") -- Output --[[ true someprefab2 does not exist ]]-- Edited June 1, 2016 by CarlZalph Mention for rezecib for quicker vanilla checks. Link to comment https://forums.kleientertainment.com/forums/topic/67817-is-there-a-way-to-distinguish-mod-prefabs-from-default-prefabs/#findComment-778809 Share on other sites More sharing options...
BluesyBuesy Posted June 1, 2016 Author Share Posted June 1, 2016 Thanks for the help @rezecib and @CarlZalph! 6 hours ago, rezecib said: @BluesyBuesy Hmm, you might be able to iterate over the modindex for their PrefabFiles tables. Let me see... It looks like GLOBAL.ModManager.loadedprefabs stores a list of (a little bit funky) mod names, which correspond to entries in the Prefabs table that list all the prefabs loaded by that mod in their dependencies. So... for _,funkymodname in pairs(GLOBAL.ModManager.loadedprefabs) do print("\nPrefabs loaded by "..funkymodname..":") for _,prefabname in pairs(GLOBAL.Prefabs[funkymodname].deps) do print(prefabname) end end You also want to make sure that you're running this after all mods you're interested in have loaded, which you can do "softly" by reducing your mod's priority in the modinfo, and you can do harder by running it from a postinit of something that loads after. Great! This is the sort of thing I was looking for. The mods and mod prefabs are unknown, so I need to fetch them from the game. Link to comment https://forums.kleientertainment.com/forums/topic/67817-is-there-a-way-to-distinguish-mod-prefabs-from-default-prefabs/#findComment-778907 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