27
« on: November 15, 2011, 10:03:49 AM »
I may as well dump a bit of info here now that Iban is gone:
Conditionals:
A little-known technique for doing quick if-checks
(<condition> ? <if true> : <if false>)
examples:
%client.chatMessage("You have" SPC %client.clamCount SPC (%client.clamCount>1 ? "clams" : "clam"));
%blah=(%use==false ? true : %use); //if %use was "bananas" then %blah would be "bananas", but if %use was false then %blah would be true
"Attaching" particle emitters to objects
This is for attaching emitters to objects when it cannot be accomplished by adding it onto a datablock, which, if you can, you should do instead. Lets start by adding the actual emitter object, we'll make it the fire A emitter:
%emitter=new ParticleEmitterNode()
{
dataBlock="GenericEmitterNode";
position="0 0 0";
emitter="burnEmitterA";
};
MissionCleanup.add(%emitter);
This isn't going to be possible without entering the emitter into some kind of loop..
%emitter.enterAttachLoop(%obj)
now lets actually set up the loop method
function ParticleEmitterNode::enterAttachLoop(%this,%obj)
{
//this is working off the assumption that you wont enter the emitter in more than once
//we make sure the object exists when we point to the object from the emitter
//while also making sure that the currently attached object exists
if(%this.attached!=%obj)
%this.attached=%obj;
if(!isObject(%this.attached))
return;
//setTransform moves the emitter to the position of the object
%this.setTransform(%obj.position SPC "0 0 0 0");
//this updates the emitters position, this is the part I'd imagine would be hard to find
%this.inspectPostApply();
//we repeat the function in 150 milliseconds, creating the loop
%this.schedule(150,0,"enterAttachLoop",%obj);
}