Jump to content

Recommended Posts

14 minutes ago, Muche said:

mainfunctions.lua/RegisterPrefabs() and mods.lua/ModWrangler:RegisterPrefabs() are filling up Prefabs table.

I've tried to using Prefabs in modmain but it not print anything.

Prefabs = GLOBAL.Prefabs

GLOBAL.rawset(GLOBAL,"print_all",function()	
	for k,v in ipairs(Prefabs) do			
		print("v="..tostring(v))		
		print("k="..tostring(k))
	end
end)

I'm want to print all prefab name have finiteuses and equippable components.

Edited by zUsername
7 hours ago, Muche said:

Prefabs is an associative table, so you'll have to use pairs instead of ipairs.

Also, looking into log, prefabs are registered after all the mods are loaded. You might need to use AddGamePostInit or AddSimPostInit.

Thanks you, It's work but are there anyway to check prefab have components ? I've tried both of code from

But @DarkXero code make the game crash, and @Maris code only print about 7 8 prefab name.

Bump. I need help again.
I've an idea make the mod load last with priority then using this

for k,v in pairs(GLOBAL.Prefabs) do
	print("123")
	AddPrefabPostInit(k, addstackable)
end

But it's not do anything in loop statement( not print "123" and add prefab ).
So any idea ? Thanks you guys.

Changing the priority won't solve it. Prefabs are registered after all the mods are loaded, a part of registering is gathering all postinits of a prefab, so any AddPrefabPostInit executed later (e.g. in AddSimPostInit/AddGamePostInit has no effect).

Could using AddPrefabPostInitAny(addstackable) help?

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...