Game Development Community

Trouble passing values

by DMT · in Torque 3D Beginner · 04/09/2010 (1:11 pm) · 2 replies

Hi, I am having trouble passing values from a GUI button to a function.

So the button has a line like this :
Command = "blahblah.Function(1);";

The function it self is just something like :

function blahblah::Function(%val){

echo(%val);
}


The trouble is that the output for this in the console will be :

blahblah

instead of :

1

So, what I am doing wrong?



#1
04/14/2010 (2:53 pm)
I believe you are adding a method to an object. When calling it, %this (which is a reference to the object the method belongs to) is the first parameter. Change the function def to

function blahblah::Function(%this, %val){

echo(%val);
}

And your test should work. What this does is allow you to reference the object and its parameters. If blahblah had something added to it like:

blahblah.myVar = "bleep";

You can then reference this value in the function as

if (%this.myVar $= "bleep")
return;

#2
04/15/2010 (1:13 pm)
Hey, thank a lot! That really helps. I completely missed the object aspect of it. This is really going to help me.