PDA

View Full Version : Global clientside variables?


wild8900
09-26-2006, 03:35 AM
How would I make/use global clientside variables using gs1 (in an editor room) were any npc (including weapons) can change the variable? I am trieing to make a bumper that npc that when you touch it, it changes a different npc's variable (the movement direction).
I am pretty rusty with gs1 and 2 so please be patient with me...

By the way, I tried excluding the 'this.' when I used the variable but meh still no luck.

Yen
09-26-2006, 03:51 AM
player.

wild8900
09-26-2006, 09:30 AM
will 'player.' this work for gs1 in the editor?

xXziroXx
09-26-2006, 03:59 PM
Lol, ANYTHING works in the editor.

ApothiX
09-26-2006, 04:16 PM
Lol, ANYTHING works in the editor.
Not everything will work in the editor.

Variables without prefixes are Global. It doesn't work like that in the editor though, because variables without prefixes prior to the new engine functioned the same way was temp. variables do now.

xXziroXx
09-26-2006, 05:10 PM
Not everything will work in the editor.

Variables without prefixes are Global. It doesn't work like that in the editor though, because variables without prefixes prior to the new engine functioned the same way was temp. variables do now.

True, what I ment was that variables work differently in the editor then they do online. For example, a serverr. var/string can be set both clientside and serverside in the editor.

ApothiX
09-26-2006, 06:10 PM
True, what I ment was that variables work differently in the editor then they do online. For example, a serverr. var/string can be set both clientside and serverside in the editor.
O_o but you said just the opposite of that, you said "ANYTHING works in the editor"

Tolnaftate2004
09-26-2006, 06:40 PM
Not everything will work in the editor.

Variables without prefixes are Global. It doesn't work like that in the editor though, because variables without prefixes prior to the new engine functioned the same way was temp. variables do now.
Compare:
Old GraalScript

if (created) {
i=50;
test();
message #v(i);
}
function test() {
i=30;
return;
}
The above code displays "30"

New GraalScript

function onCreated() {
temp.i=50;
test();
message(temp.i);
}
function test() {
temp.i=30;
return;
}
The above code displays "50"

And another thing, in the editor, I placed two scripts:
if (created) i=234;
if (created) message #v(i);
And the second displayed "234"

Let's not confuse people with false information now. Variables without prefixes are global, and have been global (with some exceptions).

xXziroXx
09-26-2006, 06:44 PM
O_o but you said just the opposite of that, you said "ANYTHING works in the editor"

Yeah but, ugh, I ment like.. bah, I ment that it doesnt mather if you have try to set a serverr. clientside, it WORKS in the editor. You can name a var global.pievar.of.leetness and it will most likely work in the editor.

ApothiX
09-29-2006, 02:20 PM
Compare:
Old GraalScript

if (created) {
i=50;
test();
message #v(i);
}
function test() {
i=30;
return;
}
The above code displays "30"

New GraalScript

function onCreated() {
temp.i=50;
test();
message(temp.i);
}
function test() {
temp.i=30;
return;
}
The above code displays "50"

And another thing, in the editor, I placed two scripts:
if (created) i=234;
if (created) message #v(i);
And the second displayed "234"

Let's not confuse people with false information now. Variables without prefixes are global, and have been global (with some exceptions).
They are global, but they they are only global to that one NPC. In the new engine, any NPC running in the same scope can access an unprefixed variable. They are removed after script execution is complete, just like the temp.prefix variables.

Try not to correct me unless you know what you're talking about, and what context the question was phrased in.

Tolnaftate2004
09-29-2006, 06:01 PM
They are removed after script execution is complete, just like the temp.prefix variables.
See Ex. 1.
They are global, but they they are only global to that one NPC. In the new engine, any NPC running in the same scope can access an unprefixed variable.
See Ex. 2.

You are wrong.