Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Array Problems (https://forums.graalonline.com/forums/showthread.php?t=75726)

HolySheepy 07-20-2007 07:52 PM

Array Problems
 
PHP Code:

//#CLIENTSIDE
function onCreated(){
  
this.meowarray = { };
  for( 
temp.ay 0temp.ay 64temp.ay++ ){
    for( 
temp.ax 0temp.ax 64temp.ax++ ){
      
this.meowarraytemp.ax ][ temp.ay ] = 1;
      if( 
temp.ax == && temp.ay == ) echo( this.meowarraytemp.ax ][ temp.ay ] );      
    }
  } 


it echoes 0 x.x
why that?

JkWhoSaysNi 07-20-2007 10:32 PM

At a guess i'd say the problem is that mewoarray is only defined as an array and you're using it as a 2d array.
Try this:

PHP Code:

function onCreated(){
  
this.meowarray = { };
  for( 
temp.ay 0temp.ay 64temp.ay++ ){
    
this.meowarray[temp.ay] = {};
    for( 
temp.ax 0temp.ax 64temp.ax++ ){
      
this.meowarraytemp.ay ][ temp.ax ] = 1;
      if( 
temp.ax == && temp.ay == ) echo( this.meowarraytemp.ay ][ temp.ax ] );      
    }
  } 


HolySheepy 07-21-2007 12:09 AM

yeah, but i used this.meowarray = new[64][64] now
thanks anyway

coreys 07-21-2007 02:20 AM

You shouldn't need to do that. o.0
I've never had to define an array. =o
Actually I ussually just set the variable to NULL, and then add the array members in the for loop, so far it hasn't caused me problems. o.0


All times are GMT +2. The time now is 07:16 PM.

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