zUsername Posted February 11, 2016 Share Posted February 11, 2016 Are there anyway to get all prefab name ? Include prefab name provide by other mods ? Link to comment Share on other sites More sharing options...
Muche Posted February 11, 2016 Share Posted February 11, 2016 mainfunctions.lua/RegisterPrefabs() and mods.lua/ModWrangler:RegisterPrefabs() are filling up Prefabs table. Link to comment Share on other sites More sharing options...
zUsername Posted February 11, 2016 Author Share Posted February 11, 2016 (edited) 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 February 11, 2016 by zUsername Link to comment Share on other sites More sharing options...
Muche Posted February 12, 2016 Share Posted February 12, 2016 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. Link to comment Share on other sites More sharing options...
zUsername Posted February 12, 2016 Author Share Posted February 12, 2016 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. Link to comment Share on other sites More sharing options...
Muche Posted February 12, 2016 Share Posted February 12, 2016 I tried DarkXero's code and it did indeed crash when trying it in the menu or as the client. However it worked when run on the server. Link to comment Share on other sites More sharing options...
zUsername Posted February 12, 2016 Author Share Posted February 12, 2016 Hmm It's seem impossible to use AddPrefabPostInit in AddSimPostInit. Anyway thanks you @Muche Link to comment Share on other sites More sharing options...
zUsername Posted February 14, 2016 Author Share Posted February 14, 2016 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. Link to comment Share on other sites More sharing options...
Muche Posted February 14, 2016 Share Posted February 14, 2016 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? Link to comment Share on other sites More sharing options...
zUsername Posted February 14, 2016 Author Share Posted February 14, 2016 Good idea. Let me try. Thanks you @Muche Link to comment 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