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 02-15-2007, 06:14 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
"Reversing" Arrays

Hrm, is there a function that reverses a array?
like
this.array[ 0 ] = 2;
this.array[ 1 ] = 3;
this.array[ 2 ] = 1;

now this.array.reverse(); or something like this would make

this.array[ 0 ] == 1;
this.array[ 1 ] == 3;
this.array[ 2 ] == 2;
Reply With Quote
  #2  
Old 02-15-2007, 07:44 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Make a function for it..?
__________________
Reply With Quote
  #3  
Old 02-15-2007, 07:52 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Can I ask why you would want to do this?

PHP Code:
  temp.myArray = {35"test"};
  for (
temp.curPar = (temp.myArray.size() - 1); temp.curPar > -1temp.curPar--)
  {
    
temp.newArray.add(temp.myArray[temp.curPar]);
  }
  echo(
temp.newArray); 
Reply With Quote
  #4  
Old 02-15-2007, 08:01 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
making a function is easy

but before i make a function i ask if theres already another function that does the same thing
Reply With Quote
  #5  
Old 02-15-2007, 08:02 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by projectigi View Post
making a function is easy

but before i make a function i ask if theres already another function that does the same thing

You should check the wiki more often.
Reply With Quote
  #6  
Old 02-15-2007, 08:10 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by projectigi View Post
making a function is easy

but before i make a function i ask if theres already another function that does the same thing
There isn't an option
Reply With Quote
  #7  
Old 02-15-2007, 09:27 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
There is not (yet). We could add a few more string and array operators if wanted though.
Reply With Quote
  #8  
Old 02-16-2007, 12:15 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Well, the wiki's search function sucks
Reply With Quote
  #9  
Old 02-16-2007, 01:57 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by projectigi View Post
Well, the wiki's search function sucks
Go to for example the clientside scripting page, CTRL + F and type in what you are looking for. Voilá, check mate.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 02-16-2007, 02:06 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Some string functions I use sometimes.

ReverseArray:
PHP Code:
public function reversearray(temp.array) {
  
temp.newarray;
  
temp.i;
  
  
newarray "";
  for (
= array.size() - 1> -1--) {
    
newarray.add(array[i]);
  }
  return 
newarray;

ReverseString:
PHP Code:
public function reversestring(temp.string) {
  
temp.i;
  
temp.out;
  
  for (
string.length() - 1> -1--) {
    
out @= string.charat(i);
  }
  return 
out

ReplaceSubString:
PHP Code:
public function replacesubstring(temp.stringtemp.positiontemp.lengthtemp.newstring) {
  
temp.stringa;
  
temp.stringb;
  
temp.outstring;
  
  if (
position 0) {
    return;
  }
  
stringa string.substring(0position);
  
stringb string.substring(position length, -1);
  
outstring stringa newstring stringb;
  return 
outstring;

__________________
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 12:21 AM.


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