Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: 3D Array  (Read 3522 times)

0 Members and 1 Guest are viewing this topic.

Adventure Bird

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
3D Array
« on: August 13, 2010, 04:57:38 PM »

It's long time ago since I used my last 3D array that uses normal arrays.

Maybe somebody could help me.
Here is the code:
Code: [Select]

var Spielfeld;
function initSpielfeld()
{
Spielfeld = new Array(15);
for ( var x = 1; x <= 15; x=x+1)
{
Spielfeld[x] = new Array(12);
for( var y = 1; y <= 3; y=y+1 )
{
Spielfeld[x][y] = new Array(3); // HERE is the problem with the two brackets
for (var z = 1; z <= 12; z=z+1 )
{
Spielfeld[x][y][z] = 0;
}
}
}
}
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: 3D Array
« Reply #1 on: August 13, 2010, 06:22:04 PM »

use tmp variable

Code: WME Script
  1.  
  2. var tmp = spiel[x];
  3. tmp[x] = 17;
  4.  
  5. spiel[x] = tmp;
  6.  
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Adventure Bird

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: 3D Array
« Reply #2 on: August 13, 2010, 10:38:28 PM »

Thanks a lot.
Logged
 

Page created in 0.022 seconds with 24 queries.