Author Topic: Variable that changes value without function  (Read 1327 times)

I was wondering if there was a way to make a variable change without calling a function to do it. I don't know what to call it. If anyone could help me I would greatly appreciate it.

Code: [Select]
$b = 1;did i just blow your mind?

no but really i don't understand what you mean

Code: [Select]
$b = 1;did i just blow your mind?

no but really i don't understand what you mean

%a = %b + %c so every time b or c changes, a automatically changes.

So basically, what you're asking

is for a variable
which changes its value


on its own, without being told.



You really haven't thought that through, have you?

-Never mind port beat me to it-

I don't know what to call it.

Sounds like you're describing pointers. To my knowledge, they do not exist in torquescript.
« Last Edit: November 16, 2013, 05:22:43 AM by Zelothix »

%a = %b + %c so every time b or c changes, a automatically changes.

What is wrong with programmatically retrieving A (e.g. getAValue()) or setting it when another variable is set using a function (setBValue and setCValue implicitly modify A)?
« Last Edit: November 16, 2013, 05:08:53 AM by Port »

-Never mind port beat me to it-

Sounds like you're describing pointers. To my knowledge, they do not exist in torquescript.
Yea that's pretty much what he's describing. In TS, you'll have to use some easy trickery to make the value automatically update, or update before use using functions like port suggested

of course torque has pointers, not that you can access without changing the engine though

-Never mind port beat me to it-

Sounds like you're describing pointers. To my knowledge, they do not exist in torquescript.

I thought it might be pointers, my professor said it was possible to do this with classes in c++. She never really explained it that well though.

What you're describing is only really possible if this "variable" is really a function, and evaluates the result each time it is accessed.

What you're describing is only really possible if this "variable" is really a function, and evaluates the result each time it is accessed.

So when she was describing this to me, that means a variable would be a function of a class? Because she never really answered my question, she just told me it was possible. She said she would answer it later but didn't.

Because she never really answered my question, she just told me it was possible. She said she would answer it later but didn't.

Well using getters and setters, sure, it's possible, but TorqueScript doesn't have those.

Well using getters and setters, sure, it's possible, but TorqueScript doesn't have those.
Exactly. You need to actually define a function and use global variables to do this.