Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-18-2005, 05:54 PM
Fry Fry is offline
Registered User
Fry's Avatar
Join Date: Sep 2001
Location: Germany
Posts: 384
Fry has a spectacular aura about
GS2: Local variables

I was wondering, Torque Script has them, so why have them be removed from GS2? Having those would really easen things.
I'd guess there were some problems including them, but I'd really appreciate it if we could get something similar.

(I am talking about variables that won't exist over the current scope, like explained in http://tork.beffy.de/uploads/liquid.net/tutorial1.htm)
__________________
Graal Statistics

Top 3 servers at the moment (players):


Reply With Quote
  #2  
Old 05-18-2005, 06:14 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Fry
I was wondering, Torque Script has them, so why have them be removed from GS2? Having those would really easen things.
I'd guess there were some problems including them, but I'd really appreciate it if we could get something similar.

(I am talking about variables that won't exist over the current scope, like explained in http://tork.beffy.de/uploads/liquid.net/tutorial1.htm)
You mean temp. variables ?
In new Graal script variables are by default global (like in old scripting engine on clientside), and you can limit the scope by putting this., player., server., temp. etc. in front.
Reply With Quote
  #3  
Old 05-18-2005, 06:14 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
The only way to do local variables right now is define them in the function arguments. I agree with you, the removal of local/global variable scope sucks.

Quote:
Originally Posted by Stefan
You mean temp. variables ?
temp.?

In TorqueScript you have %local, and $global variables.
Reply With Quote
  #4  
Old 05-18-2005, 06:29 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Rick
temp.?
Function parameters are temp. variables, you can call a variable temp.something to make it only work in the current function body or if you want to do a recursive function.

Quote:
Originally Posted by Rick
In TorqueScript you have %local, and $global variables.
In Graal script % is an operator (modulus), and like I said it is needed for compatibility so that the old Graal scripts work the same.
Reply With Quote
  #5  
Old 05-18-2005, 06:32 PM
Fry Fry is offline
Registered User
Fry's Avatar
Join Date: Sep 2001
Location: Germany
Posts: 384
Fry has a spectacular aura about
Quote:
Originally Posted by Stefan
You mean temp. variables ?
In new Graal script variables are by default global (like in old scripting engine on clientside), and you can limit the scope by putting this., player., server., temp. etc. in front.
Well, I don't know how temp. vars act, but I was talking about variables that won't exist in (as example) a function called by the function, like

function foo() {
foovar = "hello";
bar();
}

Now function bar shouldn't have access to foovar, yet it does and it is one big source for errors.
Like when you use some function someone else made, and it changes a variable you use in your function that calls this 3rd party function.

EDIT: A-hah, so temp. vars replace them Well, that answers my question, thanks very much.
__________________
Graal Statistics

Top 3 servers at the moment (players):


Reply With Quote
  #6  
Old 05-18-2005, 06:48 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Fry
Now function bar shouldn't have access to foovar, yet it does and it is one big source for errors.
Yes it can be confusing sometimes, but it was the only way in the old scripting engine to pass parameters to the called function so it cannot be just removed. It could be possible to add the possibility to modify the scope of variables by serveroptions may be, although it can be even more confusing if the same script works differently from server to server.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:36 PM.


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