Jump to content

Recommended Posts

@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 by rezecib

@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 by CarlZalph
Mention for rezecib for quicker vanilla checks.

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. 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...