Author Topic: How do '%x.y' and '%x.y["z"]' variables work?  (Read 772 times)

echo(%title);
No but seriously, I would really like to know.

What are you asking?

If you're asking about arrays, the best way to put it is that TorqueScript arrays basically just let you define variables with arbitrary appendages.

e.g.
%blah[5] is the same as %blah5

%blah["hello"] is the same as %blahhello

%blah[5, "hello"] is the same as %blah5_hello (i think)

The content inside the array can be a variable as well.

What are you asking?

If you're asking about arrays, the best way to put it is that TorqueScript arrays basically just let you define variables with arbitrary appendages.

e.g.
%blah[5] is the same as %blah5

%blah["hello"] is the same as %blahhello

%blah[5, "hello"] is the same as %blah5_hello (i think)

The content inside the array can be a variable as well.
Hmmmm... What if the string in the array has spaces? Would %blah["The Great Monster"] become %blahThe_Great_Monster, or what?

Hmmmm... What if the string in the array has spaces? Would %blah["The Great Monster"] become %blahThe_Great_Monster, or what?
No, it would be %blahThe Great Monster
Since this isn't proper syntax, it would only be accessible through the array %blah["The Great Monster"]

TorqueScript's implementation of arrays is very shoddy.
If you were to export this array (export("%blah*","filepath");)
And since it isn't correct syntax, if would give an error if you tried to reload it




As for your first question "%x.y"
If an object, %x, exists, it can have fields defined on it.
As easy example is %client.bl_id
%client is an object of class GameConnection, and bl_id is a value stored on it
« Last Edit: June 20, 2013, 08:11:29 PM by Headcrab Zombie »