Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Also a suggestion: Array enhancement (https://forums.graalonline.com/forums/showthread.php?t=59016)

Fry 05-19-2005 09:00 PM

Also a suggestion: Array enhancement
 
Well, I'd like to see simple variables that contain string or numerical values be accessable by variable[0], so instead of returning 0/nothing, it should return the value of the variable. Same goes for things like array.add(obj).
That might easen things when working with variables that are stored in the player and can be edited manually. So the script won't just stop working when you forget a "," at the end of the value.

Ajira 05-19-2005 09:10 PM

Quote:

Originally Posted by Fry
Well, I'd like to see simple variables that contain string or numerical values be accessable by variable[0], so instead of returning 0/nothing, it should return the value of the variable. Same goes for things like array.add(obj).
That might easen things when working with variables that are stored in the player and can be edited manually. So the script won't just stop working when you forget a "," at the end of the value.

I don't understand what you're trying to say. o_O

Fry 05-19-2005 09:18 PM

Quote:

Originally Posted by Ajira
I don't understand what you're trying to say. o_O

Sorry, what I meant is, if I've got, as example, client.foo with the value "bar", I want to be able to do things like client.foo.add("qux"); or client.foo[0] (which should then return "bar"). At the moment this only works when the value got a suffixing ",", meaning it gets recognized as an array.

Evil_Trunks 05-19-2005 09:19 PM

Quote:

Originally Posted by Fry
Well, I'd like to see simple variables that contain string or numerical values be accessable by variable[0], so instead of returning 0/nothing, it should return the value of the variable. Same goes for things like array.add(obj).
That might easen things when working with variables that are stored in the player and can be edited manually. So the script won't just stop working when you forget a "," at the end of the value.

? i think in gscript2 any variable used like var[0] will return the value of the variable (unless you have commas in there, which it would treat as a seperator between string list items), because it's necessary for compatibility with using string lists like that

edit: I think fry is correct, it will not work like I describe

Fry 05-19-2005 09:22 PM

Quote:

Originally Posted by Evil_Trunks
? i think in gscript2 any variable used like var[0] will return the value of the variable (unless you have commas in there, which it would treat as a seperator between string list items), because it's necessary for compatibility with using string lists like that

Well, okay, but then there are still functions like add(obj) or index(obj).
EDIT: Well, we just tried it, it doesn't work :)

Kaimetsu 05-19-2005 10:40 PM

Let me check that I've understood properly. If an array operation is performed on a non-array variable, it should be treated as a single-element array?

Velox Cruentus 05-19-2005 11:54 PM

Yea... I do believe that's what he's saying.

Evil_Trunks 05-20-2005 06:58 AM

Quote:

Originally Posted by Kaimetsu
Let me check that I've understood properly. If an array operation is performed on a non-array variable, it should be treated as a single-element array?

yeah, that's how a string list should be

Rick 05-20-2005 08:03 AM

Why?

Admins 05-22-2005 01:06 AM

For compatibility to old script?


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

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