Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   'var', what's up with 'var'? (https://forums.graalonline.com/forums/showthread.php?t=79110)

Chompy 03-21-2008 02:06 AM

'var', what's up with 'var'?
 
lets see..

PHP Code:

for(temp.var : {"rawr,rawr,rawr"}) {
  echo(var);
}
/*
error: unexpected token: var at line 2: echo(var);
error: unexpected token: ) at line 2: echo(var);
*/ 

Now, what's wrong with that? It was working perfectly before

Using var can't be used anywhere any longer?
And is now being used as:
PHP Code:

var foo 2;
echo(
foo); 

similar to javascript? hmm?

What's with the sudden use of var? I now have to rescript all scripts on Symphonia just because the use the word VAR...

PHP Code:

function test(var) {
  echo(var);
}
/*
error: unexpected symbol var at line 1: function test(var) {
*/ 


So, yet again I have to ask, whats with the sudden use of var?

cbk1994 03-21-2008 02:46 AM

I haven't noticed this o.o

Chompy 03-21-2008 03:04 AM

Quote:

Originally Posted by cbkbud (Post 1381241)
I haven't noticed this o.o

Hmm, weird, happens with all scripts that contain 'var' on symphonia.. gotta try some other places I have rc on

Tigairius 03-21-2008 03:09 AM

Quote:

Originally Posted by Chompy (Post 1381234)
PHP Code:

for(temp.var : "rawr,rawr,rawr") {
  echo(var);
}
/*
error: unexpected token: var at line 2: echo(var);
error: unexpected token: ) at line 2: echo(var);
*/ 


PHP Code:

for(temp.var : {"rawr,rawr,rawr"}) {
  echo(var);


Works fine on N-Pulse.

napo_p2p 03-21-2008 03:22 AM

Quote:

Originally Posted by Tigairius (Post 1381258)
PHP Code:

for(temp.var : {"rawr,rawr,rawr"}) {
  echo(var);


Works fine on N-Pulse.

Works fine on AEON too.

Chompy 03-21-2008 03:24 AM

Quote:

Originally Posted by Tigairius (Post 1381258)
PHP Code:

for(temp.var : {"rawr,rawr,rawr"}) {
  echo(var);


Works fine on N-Pulse.

Bah, doesn't work on symp :(

Tigairius 03-21-2008 03:27 AM

Quote:

Originally Posted by Chompy (Post 1381271)
Bah, doesn't work on symp :(

Are you including the {}?

Tolnaftate2004 03-21-2008 03:32 AM

Quote:

Originally Posted by Tigairius (Post 1381273)
Are you including the {}?

It happens in all instances of var, not just the code posted above.

Inverness 03-21-2008 03:44 AM

If you're saying it works fine then restart your NPC-Server and try again. It takes a restart for the NPC-Server to update to the latest version.

Crow 03-21-2008 04:44 PM

Works on Era, too.

Chompy 03-21-2008 04:47 PM

Still doesn't work on Symp, too. :p

zokemon 03-21-2008 06:20 PM

Maybe it's only supported on older npc servers?

napo_p2p 03-21-2008 08:59 PM

I restarted the npcserver and the var thing isn't working now, so it must be something up with the new update.

Is there a changelog somewhere? The update messed up the mud on AEON, and I have a feeling it's because of a variable that is now read only for some reason.

Crow 03-21-2008 10:05 PM

Uh-oh. Doesnt sound good. Somebody clear this up *looks around for Stefan*

cbk1994 03-21-2008 10:17 PM

You can't just take variables that are being used and disable them x.x

What the hell is wrong with Stefan?

Admins 03-21-2008 10:21 PM

We have uploaded new versions of gserver and npcserver to the playerworld machines for fixing the problem with a playerworld that was lagging a lot. There are a few modifications to the scripting: it is much faster now and we've improved the compatibility to javascript/actionscript. There are several new keywords which are basicly ignored ("static" and "var"). It was not meant to be used for other servers though, it could be possible to add a check for still allowing them as normal variables.

Crow 03-21-2008 10:38 PM

Quote:

Originally Posted by Stefan (Post 1381446)
We have uploaded new versions of gserver and npcserver to the playerworld machines for fixing the problem with a playerworld that was lagging a lot. There are a few modifications to the scripting: it is much faster now and we've improved the compatibility to javascript/actionscript. There are several new keywords which are basicly ignored ("static" and "var"). It was not meant to be used for other servers though, it could be possible to add a check for still allowing them as normal variables.

But why would it give out errors if you do something like temp.var? That shouldnt happen. Last time I checked. temp.new or something similar didnt give out anything, too, and it worked. Please add some fix, I'm already scared something will happen to the NPC-Server and somebody has to restart it D:

Inverness 03-21-2008 10:47 PM

Quote:

Originally Posted by Stefan (Post 1381446)
We have uploaded new versions of gserver and npcserver to the playerworld machines for fixing the problem with a playerworld that was lagging a lot. There are a few modifications to the scripting: it is much faster now and we've improved the compatibility to javascript/actionscript. There are several new keywords which are basicly ignored ("static" and "var"). It was not meant to be used for other servers though, it could be possible to add a check for still allowing them as normal variables.

Please do that, I use 'var' several times in the mudlib. There is also the fact that I have a global object on clientside and serverside named 'static' which I place many global variables (such as objects) that would be broke if they were viewed/saved in text format.

Stefan I would love if you'd give us a bit of warning ahead of time before you do something like that :/

cbk1994 03-21-2008 10:51 PM

Quote:

Originally Posted by Stefan (Post 1381446)
We have uploaded new versions of gserver and npcserver to the playerworld machines for fixing the problem with a playerworld that was lagging a lot. There are a few modifications to the scripting: it is much faster now and we've improved the compatibility to javascript/actionscript. There are several new keywords which are basicly ignored ("static" and "var"). It was not meant to be used for other servers though, it could be possible to add a check for still allowing them as normal variables.

You should think about making an option BEFORE you do it, not after.

Chompy 03-21-2008 11:35 PM

Yeah, the var seems to be a new update, but I don't seem to understand why it's needed, like why do we need a new type? >:[

Well, I finished rescripting everything so it didn't use 'var' some hours ago.. Took me 1 hour to look for a bug I thought was there (wasn't loading vars into a object, seemed that I was using "SCRIPT 2" and I had to edit it to work.. =/)

SCRIPT 2
PHP Code:

temp.file.loadvars("mud/archetypes/"arch @".txt");
for(
temp.var : file.getdynamicvarnames()) {
  ...
  
this.(@var) = file.(@var);


So I just changed all 'var' into 'var2'..
Still, it's kinda annoying that there's no changelog, no notice about it, but a random update no one knew about.. (Happened about 22-23 hours ago)


And about more support for javascript, why did you add var type from javascript? :o

Admins 03-22-2008 12:24 AM

Didn't know that many people are restarting their npcservers all the time. You can still use "temp.var" but not "var" alone. I will check if we can add a fix or make it optional. The new npcserver version is only on the machines for private or hosted servers, not for gold or classic.
If your server has problems then look into logs/syntaxerrors.txt

Crow 03-22-2008 12:41 AM

Quote:

Originally Posted by Stefan (Post 1381474)
Didn't know that many people are restarting their npcservers all the time. You can still use "temp.var" but not "var" alone. I will check if we can add a fix or make it optional. The new npcserver version is only on the machines for private or hosted servers, not for gold or classic.
If your server has problems then look into logs/syntaxerrors.txt

Its not only about restarting the NPC-Server. Also, if I use temp. variables, I often leave the temp. off when using it. For example, I declare temp.var (for example its 5) and then do math stuff with only var. Thats probably the biggest problem here. Maybe you can answer why we need var and static to be keywords?

Tolnaftate2004 03-22-2008 01:48 AM

This is for JavaScript/ActionScript compatibility. `var` in either of these is akin to temp. and static is a `function` qualifier. We don't need it, unless we want to use ActionScript 3. Seems good enough for me. :confused:

Quote:

Originally Posted by Stefan
We have decided to change the plan a little bit. We will improve the Graal engine to make it easier to reuse Flash scripts (action script 3). [...] it makes it easier in the future to reuse flash script or let flash scripter make games for Graal.

e: So I guess I should say (since it probably makes more sense), Stefan is saying that e.g. the ActionScript
PHP Code:

static function foo() {
  var 
bar "baz";
  return 
bar;


The static/var keywords here are ignored so that the graal engine can handle it. So your errors would arise from var being ignored (you'd have no legal lvalue in assignment thru var = "something").

Admins 03-22-2008 01:56 AM

There is also support for dots in class names and "import" and an extension to the new constructor, but like i said its more experimental. It's basicly for easier cut & paste of existing scripts. The keywords "var" and "static" are currently ignored, so when you start a code line with those words it is ignoring them and of course seeing an error in the following script. It's possible to switch the npcserver back to the old version until that problem is fixed, if it's really a big problem.

zokemon 03-22-2008 05:03 AM

Jesus guys, why don't you just name your damn variables as v instead of var? I rarely use temp variables that are more then 2 letters in length.

Also, just script scan, F3 and ctrl+v a bunch of times and your var problem is fixed (be sure to enable fullword only).

I've replaced variable names on my whole server many times and it only took me about 5 minutes tops to replace about 70 instances or so.

cbk1994 03-22-2008 05:06 AM

Quote:

Originally Posted by zokemon (Post 1381511)
I rarely use temp variables that are more then 2 letters in length.

Same, but I'll name this. variables and others better.

zokemon 03-22-2008 05:30 AM

Quote:

Originally Posted by cbkbud (Post 1381514)
Same, but I'll name this. variables and others better.

Me too! Let's start a club.

cbk1994 03-22-2008 06:35 AM

Quote:

Originally Posted by zokemon (Post 1381517)
Me too! Let's start a club.

OK! :D

Admins 03-28-2008 12:45 PM

Ok the npcserver has been updated, you can now use "var" as function parameter and variable name again. The built-in values "NULL", "true", "false" and "pi" also work as function parameter names again instead of displaying an error.


All times are GMT +2. The time now is 01:56 AM.

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