Rtd Posted October 16, 2014 Share Posted October 16, 2014 Hi ! First, let me say I'm by far not an expert in Lua, and pretty much new to DS mods. What I'm trying to do, is to replace a callback used in one prefab by the proper way.Overriding the prefab is fun, but I feel like I shouldn't do this anymore and that's why I'm asking you some help for this. So, let's say that in the fn function of a prefab there is a :inst.Physics:SetCollisionCallback( prefabcollisioncallback )and I what to replace it by mine. Will a simple :function mycollisioncallback (inst) returnendAddPrefabPostInit("theprefab", function(inst) if inst then inst.Physics:SetCollisionCallback( mycollisioncallback ) endend)do it ? Or is there some magic underneath this that I'm not aware and will cause some wierd things to happen ? Thanks for your help in advance ! Link to comment https://forums.kleientertainment.com/forums/topic/42160-replacing-physics-callbacks/ Share on other sites More sharing options...
Mobbstar Posted October 16, 2014 Share Posted October 16, 2014 I don't see why it shouldn't work. The if inst then seems unnecessary to me. Link to comment https://forums.kleientertainment.com/forums/topic/42160-replacing-physics-callbacks/#findComment-552184 Share on other sites More sharing options...
Rtd Posted October 16, 2014 Author Share Posted October 16, 2014 Thank you for your reply ! Yeah, I know... ^^' Anyway, what I'm afraid of, is that the SetCollisionCallback will create a duplicate entry for the same collision event, causing it to call two functions (the original one and the one I defined) instead of the only one I defined.And since I can't find any reference to the SetCollisionCallback function in the game scripts, I'm stuck.I've read Physics.lua already but it doesn't help me at all...Maybe it's my lack in Lua experience and DS scripting that's stucking me here... ^^' (Oh, and don't hesitate to ask me to reformulate please : English is not my native language... ) Link to comment https://forums.kleientertainment.com/forums/topic/42160-replacing-physics-callbacks/#findComment-552200 Share on other sites More sharing options...
seronis Posted October 16, 2014 Share Posted October 16, 2014 'SetSomeAttribute' generally means it replaces the previous attribute 'AddSomeAttribute' is how things get named if previous entries arent purged Id just trust that Klei named the function appropriately and things will work as expected for your new handler. Link to comment https://forums.kleientertainment.com/forums/topic/42160-replacing-physics-callbacks/#findComment-552401 Share on other sites More sharing options...
Rtd Posted October 17, 2014 Author Share Posted October 17, 2014 Okay... -.-Somehow I missed that! xD Thank you very much! Link to comment https://forums.kleientertainment.com/forums/topic/42160-replacing-physics-callbacks/#findComment-552701 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