Game Development Community

Returning a value from a dynamic field.

by Jon Mitchell · in Torque Game Builder · 12/14/2006 (12:36 pm) · 4 replies

At first I though it would be a piece of cake to simply return a value from a dynamic field of an object. In another life I would have though it would be something like this:

$var = dfield();

and if you and echo of $var you would get back of what ever you had gived the dynamic field for a value, which I though I had confirmed this was correct after doing the 2d side shooter demo, but I am wrong. What is the correct way to return the value of a dynamic field into a $variable


Thank you! :-)

#1
12/14/2006 (12:45 pm)
If you have an object %x with a field f, it would be:
$var = %x.f;
#2
12/14/2006 (1:53 pm)
Hi Lance,
So if I have a person who can toss a ball, the throw distance dynamic field is called throwDistance and the class object is called balltosser (should I be using the class or the name?) and I want to return the distance to toss then should it look something like this?

$throwDistance = %balltosser.throwDistance;



and if I were to echo $throwDistance in theory it would return the value on how far to toss?
#3
12/14/2006 (2:50 pm)
You should be using either the name of the object or the id of the object, not the class. Your example looks correct.
#4
12/14/2006 (4:31 pm)
Thank you :)