Jump to content

Replacing physics callbacks


Rtd

Recommended Posts

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
Share on other sites

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... :friendly_wink:  )

Link to comment
Share on other sites

'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
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...