Where to call script after unpackUpdate ?
by Orion Elenzil · in Torque Game Engine · 03/02/2006 (4:30 pm) · 5 replies
After a player::unpackUpdate(),
i'd sometimes like to make some calls into script,
eg Player::onSomePropertyChanged(%this).
is there a good way to do that ?
i'd sometimes like to make some calls into script,
eg Player::onSomePropertyChanged(%this).
is there a good way to do that ?
About the author
#2
i know how to call script,
i'm just leery of calling possibly lengthy script functions inside of unpackUpdate().
03/02/2006 (4:44 pm)
Thanks anthony -i know how to call script,
i'm just leery of calling possibly lengthy script functions inside of unpackUpdate().
#3
03/02/2006 (5:18 pm)
Im doing it now for hitpoint updates. It shouldnt effect anything calling it there. But if your really concerned you could set a bool "onDataChanged" and in the processTick, call your script if that var is set.
#4
thanks very much peter.
what about doing something like this:
03/02/2006 (5:30 pm)
processTick!thanks very much peter.
what about doing something like this:
[b]change this:[/b]
function player::somethingChanged(%this)
{
doLengthScriptOperation();
}
[b]to this:[/b]
function player::somethingChanged(%this)
{
%this.schedule(0, "somethingChangedReally");
}
function player::somethingChangedReally(%this)
{
doLengthScriptOperation();
}
#5
a major reason to watch out for calling to script directly from unpackUpdate,
and why Peter's processTick suggestion is a better method:
when the client is first ghosted an object,
it seems to me and my colleagues that the object is not assigned a simID until the unpackUpdate is finished.
so,
if you're doing something like this inside unpackUpdate:
you may find that on the script side, %this is zero, even tho this in C++ was valid.
So what i'm currently planning to do is a slight generalization of Peter's "onDataChanged" idea:
add a new member to netObject: mDirtyMaskBitsClient,
and set bits in it individually in unpackUpdate(), and then have various clearers in processTick.
03/03/2006 (10:12 am)
Update:a major reason to watch out for calling to script directly from unpackUpdate,
and why Peter's processTick suggestion is a better method:
when the client is first ghosted an object,
it seems to me and my colleagues that the object is not assigned a simID until the unpackUpdate is finished.
so,
if you're doing something like this inside unpackUpdate:
Con::executef(this, 1, "somethingChanged");
you may find that on the script side, %this is zero, even tho this in C++ was valid.
So what i'm currently planning to do is a slight generalization of Peter's "onDataChanged" idea:
add a new member to netObject: mDirtyMaskBitsClient,
and set bits in it individually in unpackUpdate(), and then have various clearers in processTick.
Associate Anthony Rosenbaum