Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   array modifiers (https://forums.graalonline.com/forums/showthread.php?t=64419)

Prozac 02-27-2006 09:38 PM

array modifiers
 
Let's say I have an array:
PHP Code:

this.fuit={"apple","orange","bananna"}; 

and you want to add "pear" to the array.
What would it involve to get the array to look like:
PHP Code:

this.fuit={"apple","orange","bananna","pear"}; 

or
PHP Code:

this.fuit={"pear","apple","orange","bananna"}; 

or
PHP Code:

this.fuit={"apple","orange","pear","bananna"}; 

?

and what is involved in removing an item from an array of strings and having the array self-compress so there are no emty spaces, such as:
before
PHP Code:

this.fuit={"apple","orange","bananna"}; 

and after
PHP Code:

this.fuit={"apple","bananna"}; 

?

Ajira 02-27-2006 09:54 PM

PHP Code:

varname.add("str");
varname.remove("str");
varname.insert(index"str");
varname.delete(index); 


jake13jake 02-28-2006 05:26 AM

Ajira's right, but that doesn't work for multidimensional arrays (yet?)

ApothiX 02-28-2006 06:23 AM

Quote:

Originally Posted by jake13jake
Ajira's right, but that doesn't work for multidimensional arrays (yet?)

Yes it does, array[index].add() etc.

jake13jake 02-28-2006 07:15 AM

Quote:

Originally Posted by ApothiX
Yes it does, array[index].add() etc.

Well, I was having problems with it. This is what I meant about the problem of using the standard object stuff on a specific dimension of an array:
Quote:

Originally Posted by Stefan
A well known problem yes, it is not telling the 'parent' (next lower dimension) that it has been updated. That's why it's not displaying the right stuff when being output as string, will check if this can been fixed soon.


Rick 02-28-2006 07:27 AM

That's just visual... the value has changed.

ApothiX 02-28-2006 03:24 PM

I've never had problems using array[index].add() and such.

Edit: Ah, didn't see Rick's post, but he is right :p

jake13jake 02-28-2006 10:03 PM

Quote:

Originally Posted by ApothiX
I've never had problems using array[index].add() and such.

Edit: Ah, didn't see Rick's post, but he is right :p

But visually it can be very important.

Rick 03-01-2006 07:00 AM

...why? Do you normally show raw array contents to people?

ApothiX 03-01-2006 03:13 PM

Quote:

Originally Posted by Rick
...why? Do you normally show raw array contents to people?

Who doesn't?!


All times are GMT +2. The time now is 05:38 PM.

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