Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Global clientside variables? (https://forums.graalonline.com/forums/showthread.php?t=68968)

wild8900 09-26-2006 03:35 AM

Global clientside variables?
 
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

Quote:

Originally Posted by xXziroXx (Post 1222467)
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

Quote:

Originally Posted by ApothiX (Post 1222472)
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

Quote:

Originally Posted by xXziroXx (Post 1222494)
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

Quote:

Originally Posted by ApothiX (Post 1222472)
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
PHP Code:

if (created) {
  
i=50;
  
test();
  
message #v(i);
}
function 
test() {
  
i=30;
  return;


The above code displays "30"

New GraalScript
PHP Code:

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:
PHP Code:

if (createdi=234

PHP Code:

if (createdmessage #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

Quote:

Originally Posted by ApothiX (Post 1222516)
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

Quote:

Originally Posted by Tolnaftate2004 (Post 1222523)
Compare:
Old GraalScript
PHP Code:

if (created) {
  
i=50;
  
test();
  
message #v(i);
}
function 
test() {
  
i=30;
  return;


The above code displays "30"

New GraalScript
PHP Code:

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:
PHP Code:

if (createdi=234

PHP Code:

if (createdmessage #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

Quote:

Originally Posted by ApothiX
They are removed after script execution is complete, just like the temp.prefix variables.

See Ex. 1.
Quote:

Originally Posted by ApothiX
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.


All times are GMT +2. The time now is 07:11 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.