kiopho Posted December 28, 2013 Share Posted December 28, 2013 (edited) >>SOLVED<< Hi there !I haven't been modding lately and I feel a bit rusty.So, I'm trying to make the reveal radius from my mod 'Wide FOV' work with custom characters. I'm using this for the vanilla characters :for k,prefabname in ipairs(CHARACTERLIST) doAddPrefabPostInit(prefabname, addRevealer)endwhere addRevealer is the function for the reveal radius.Any help is welcome and happy holydays ! Edited December 29, 2013 by kiopho Link to comment https://forums.kleientertainment.com/forums/topic/30599-modcharacterlist/ Share on other sites More sharing options...
squeek Posted December 28, 2013 Share Posted December 28, 2013 (edited) What is the addRevealer function doing? If it's not adding a component (or if it is adding a component that doesn't need to save/load any data), just use AddSimPostInit instead. The callback function of that gets called with the player prefab as the parameter, no matter the character. However, if it is adding a component and that component needs to save/load data, then see the Adding components to all players section of my Code Tips and Tricks thread. Edited December 28, 2013 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/30599-modcharacterlist/#findComment-394805 Share on other sites More sharing options...
Heavenfall Posted December 28, 2013 Share Posted December 28, 2013 (edited) for k,prefabname in ipairs(GLOBAL.MODCHARACTERLIST) doAddPrefabPostInit(prefabname, addRevealer)end should work, just be sure you are loading after any characters are loaded by setting a very low priority in modinfo Edited December 28, 2013 by Heavenfall Link to comment https://forums.kleientertainment.com/forums/topic/30599-modcharacterlist/#findComment-394833 Share on other sites More sharing options...
kiopho Posted December 29, 2013 Author Share Posted December 29, 2013 (edited) Thanks a lot for the help guys, I got it working. @squeek It expands the reveal radius on the map to match the custom FOV. So it needs to save the extra map space revealed. But that's working fine. Thanks for the link mate. @Heavenfall That's what I used but it didn't work because the custom character I was testing with had its priority higher than my mod. And of course the priority system went way over my head :/ Now it works fine. When you focus too much on a problem, you may end up missing the most obvious ><if GLOBAL.MODCHARACTERLIST thenfor k,prefabname in ipairs(GLOBAL.MODCHARACTERLIST) doAddPrefabPostInit(prefabname, addRevealer)endend Edited December 29, 2013 by kiopho Link to comment https://forums.kleientertainment.com/forums/topic/30599-modcharacterlist/#findComment-395025 Share on other sites More sharing options...
simplex Posted December 29, 2013 Share Posted December 29, 2013 (edited) However, if it is adding a component and that component needs to save/load data, then see the Adding components to all players section of my Code Tips and Tricks thread.That would be the way to handle this without depending on load priority. Though I suppose it's a more complex solution.If you'd like to update that tip with a more "user-friendly" presentation, here's the method wrapped in a function (used just like AddSimPostInit):function AddPlayerPrefabPostInit(postinitfn) AddPrefabPostInit("world", function() GLOBAL.assert( GLOBAL.GetPlayer() == nil ) local player_prefab = GLOBAL.SaveGameIndex:GetSlotCharacter() -- Unfortunately, we can't add new postinits by now. So we have to do -- it the hard way... GLOBAL.TheSim:LoadPrefabs( {player_prefab} ) local oldfn = GLOBAL.Prefabs[player_prefab].fn GLOBAL.Prefabs[player_prefab].fn = function(Sim) local player = oldfn(Sim) postinitfn(player) return player end end)endEDIT: I hadn't noticed until now I was shadowing an inst variable with another in a deeper scope. The code itself was correct, but nevertheless this is something that greatly hurts code legilibity and is prone to errors, so I fixed it. Edited December 29, 2013 by simplex Link to comment https://forums.kleientertainment.com/forums/topic/30599-modcharacterlist/#findComment-395253 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