Author Topic: explodeOnDeath for debris  (Read 5759 times)

I'm trying to script this seemingly simple thing from scratch seeing as it's a basic function that should be included anyways and I thought it would be a good starting point. Problem is, I'm stuck at what %vars to put into the function's argument string thing.

Code: [Select]
function DebrisData::onDeath(%this, %obj, ???) {}
I'm trying to figure out what the variable for object Death is. I've been looking around the forums for scripts and examples that might contain it but I haven't had much luck. Maybe I could use the Debris' own lifeTime variable? But then I'm not even sure what that var is called.

I'm in a pickle, could someone help me out?

why do you need anymore then those 2 args?


Use trace(1); to switch tracing on and trace(0); to switch tracing off. This will allow you to see what variables are going into a function, you will get the variable's handle if it's an object in which case you can do <handle>.dump(); to find out what it is.

Variable names don't matter in Torque, you can just do onDeath(%cake, %fruit, %cheese);

I'm in a pickle, could someone help me out?

Ahaha he heard you. Its like the loving bat signal!

Variable names don't matter in Torque, you can just do onDeath(%cake, %fruit, %cheese);

Just to prove you wrong "for old time's sake" parameter names don't matter in any language as far as I know. Oh and I just realised how pointless and stupid your suggestion was. Haha for that.

Try onExplode

Whoops wasn't thinking. Since Debris isn't actually a real world object (just a client-side rendering i think) and isn't networked, it doesn't have an object ID and therefore won't have any object-specific callbacks. So no, you can't do anything when a debris thing explodes.
« Last Edit: December 18, 2008, 03:58:16 PM by Ephialtes »

Just to prove you wrong "for old time's sake" parameter names don't matter in any language as far as I know.

It does in C++, if you're trying to pre-define a function.

It does in C++, if you're trying to pre-define a function.


No, you dont have to match up the parameters in a function call with the variable names in the function header itself. For someone who "moved onto bigger and better things" you're still stunningly stupid.

No, you dont have to match up the parameters in a function call with the variable names in the function header itself. For someone who "moved onto bigger and better things" you're still stunningly stupid.

Modern compilers will correct it for you.

Modern compilers will correct it for you.

Er, never heard of this - also its not something the programmer has to be aware of and is therefore not a requirement.

Try onExplode

But it doesn't explode, it just dies if it's mid-air and it's lifetime runs out. Does it still explode, only it doesn't call an explosion datablock? I'll try this out though.

why do you need anymore then those 2 args?


Oh good point, I don't know what I need to put in that string. I might need the %pos argument since I need to create the explosion where the debris dies, somehow. I also need to orient the explosion to point in the same direction as the debris. I don't know if I should put those arguments up in the string or not.

So far I made this

Code: [Select]
function DebrisData::onDeath(%this, %obj,)
{
if(%obj.destroyed == 1)
      new Explosion()
      {
         dataBlock = TESTbowDebriloveplosion;
         initialPosition = ???
      };
}

Since Debris isn't actually a real world object (just a client-side rendering i think) and isn't networked, it doesn't have an object ID and therefore won't have any object-specific callbacks. So no, you can't do anything when a debris thing explodes.

Yeah, the compiler does it - its not something the programmer has to be aware of and is therefore not a requirement.

You do if you're coding on an old compiler.

You do if you're coding on an old compiler.

Haha, Still stubborn as an ass. Show me something that says this is the case because I have never heard this before ever. Infact no, you're an idiot. That is most blatantly not the case at all because a variable name is just an identifier for a value or memory location and any code that relies on you matching the parameters in a function call to the function definition itself cannot be a mainstream programming language.

@Muffinmix: You also can't spawn explosions like that - they won't be networked so only the host will be able to see them. You need to create a projectile with a lifetime of 0 and an explodeOnDeath or something.
« Last Edit: December 18, 2008, 04:21:22 PM by Ephialtes »

@Muffinmix: You also can't spawn explosions like that - they won't be networked so only the host will be able to see them. You need to create a projectile with a lifetime of 0 and an explodeOnDeath or something.

Oh I did not know that. But, because debris objects don't have an ID then does that mean I can't do anything with them? Dang.

Oh, Pickle, surely we can continue this in Drama with another image of someone sitting on someone else's head and you having a good laugh whilst pretending it's Ephi and me in the picture when really it's the community turning against you.