Getting at variables in the script from the engine
by Owen "WDA" Ashcroft · in Torque Game Engine · 07/15/2002 (4:00 pm) · 2 replies
I am currently trying to retrieve a variable from the script.
I have added to the %p in the crossbow.cs an extra variable:
I have then added a mGeneralModifier to the projectile.cc in the form of:
Owen
I have added to the %p in the crossbow.cs an extra variable:
// Create the projectile object
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
generalModifier = %modifier; //new variable
};Like thisI have then added a mGeneralModifier to the projectile.cc in the form of:
Projectile::Projectile()
{
// Todo: ScopeAlways?
mNetFlags.set(Ghostable);
mTypeMask |= ProjectileObjectType;
mCurrPosition.set(0, 0, 0);
mCurrVelocity.set(0, 0, 1);
mSourceObjectId = -1;
mSourceObjectSlot = -1;
mGeneralModifier = 1; //default value (I assume)
mCurrTick = 0;
mParticleEmitter = NULL;
mProjectileShape = NULL;
mActivateThread = NULL;
mMaintainThread = NULL;
mHidden = false;
mFadeValue = 1.0;
}I have then added:void Projectile::initPersistFields()
{
Parent::initPersistFields();
addField("initialPosition", TypePoint3F, Offset(mCurrPosition, Projectile));
addField("initialVelocity", TypePoint3F, Offset(mCurrVelocity, Projectile));
addField("sourceObject", TypeS32, Offset(mSourceObjectId, Projectile));
addField("sourceSlot", TypeS32, Offset(mSourceObjectSlot, Projectile));
addField("generalModifier", TypeF32, Offset(mGeneralModifier, Projectile)); //Added
}Which from stuff like initialPosition appears to pull values in from the script, but obviously doesn't! as in Projectile::processTick where it emits particles the value for mGeneralModifier is the default of 1, could anyone shed some light on this (oh I declard it in the projectile.h as well as part of the structure).Owen
About the author
#2
Thanks!
07/15/2002 (6:23 pm)
Thanks, after some playing I had to add to PackUpdate not PackData but it all works.Thanks!
Torque 3D Owner Robert Blanchet Jr.
If you look for these two functions in the ProjectileData class you'll see what I mean.