Maris Posted January 16, 2015 Share Posted January 16, 2015 Now I'm using:local all_chars={"wilson","willow","wendy","wolfgang","wickerbottom","wx78"}function add_all(fn) for i=1,#all_chars do AddPrefabPostInit(all_chars[i],fn) endendadd_all(function(inst) --some common codeend)But it does not affect characters from mods. Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/ Share on other sites More sharing options...
Kzisor Posted January 16, 2015 Share Posted January 16, 2015 (edited) Now I'm using:local all_chars={"wilson","willow","wendy","wolfgang","wickerbottom","wx78"}function add_all(fn) for i=1,#all_chars do AddPrefabPostInit(all_chars[i],fn) endendadd_all(function(inst) --some common codeend)But it does not affect characters from mods. I don't know if this works, but here is what I personally use. local function SOMEFUNCTION(inst)-- DO THINGS HERE.endfor _, v in ipairs(CHARACTERLIST) do AddPrefabPostInit(v, SOMEFUNCTION)end for _, v in ipairs(MODCHARACTERLIST) do AddPrefabPostInit(v, SOMEFUNCTION)end I have this as the very last thing to run in my modmain.lua file. Edited January 16, 2015 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-602526 Share on other sites More sharing options...
rezecib Posted January 16, 2015 Share Posted January 16, 2015 Kzisor's method is more efficient, I believe, but there is an AddPlayerPostInit(fn). It uses the "player" tag, however, and technically adds a small postinit overhead to every prefab since it's added to all, then checks for the tag. Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-602531 Share on other sites More sharing options...
DarkXero Posted January 16, 2015 Share Posted January 16, 2015 AddPlayerPostInit works for official and mod characters. It's great. Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-602576 Share on other sites More sharing options...
Maris Posted January 18, 2015 Author Share Posted January 18, 2015 Thank you all for your answers!I don't like "postinit overhead", so I found best way:function AddPlayersPostInit(fn) for i,v in ipairs(MAIN_CHARACTERLIST) do -- DST_CHARACTERLIST + ROG_CHARACTERLIST AddPrefabPostInit(v,fn) end for i,v in ipairs(MODCHARACTERLIST) do AddPrefabPostInit(v,fn) endend Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-603355 Share on other sites More sharing options...
rezecib Posted January 18, 2015 Share Posted January 18, 2015 @Maris, I didn't realize it at the time, but someone pointed out in another thread that the efficient method (going through the character lists) can miss some mod characters depending on load order. You can influence your mod's load order to be later on by reducing it's priority in the modinfo:priority = -1 Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-603405 Share on other sites More sharing options...
Maris Posted January 19, 2015 Author Share Posted January 19, 2015 @rezecib, thank you very much! It's very useful information. I immediately will update my mod. Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-603643 Share on other sites More sharing options...
Maris Posted July 16, 2015 Author Share Posted July 16, 2015 (edited) Finally elegant best method to update all characters!function AddPlayersPostInit(fn) AddComponentPostInit("playervision",function(self) self.inst:DoTaskInTime(0,fn) end)end Edited July 16, 2015 by Maris Link to comment https://forums.kleientertainment.com/forums/topic/49220-addprefabpostinit-for-all-character-prefabs/#findComment-654882 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