Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Problem with "nested" variables  (Read 2160 times)

0 Members and 1 Guest are viewing this topic.

Javi-Wan Kenobi

  • Supporter
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Problem with "nested" variables
« on: February 28, 2008, 07:28:37 PM »

I want keep a series of data from a scene in the Statescene variable.
Since many of the data are arrays, I declare them like this in the scene_init.script:
Code: [Select]
if(!StateSomewhere.Visited)
{
  StateSomewhere.Visited = true;

  // this is our first visit in this scene...
  StateSomewhere.p1 = new Array("eje1", 108, 39);
  StateSomewhere.p2 = new Array("eje1", -94, 18);
  StateSomewhere.p3 = new Array("eje1", -94, 18);
  StateSomewhere.p4 = new Array("eje1", -94, 18);
  StateSomewhere.c1 = new Array(4, 3, 2, 1);
  StateSomewhere.c2 = new Array();
  StateSomewhere.c3 = new Array();
 
// etc...
}
But the problem come later, when I want to use those variables, for example:
Code: [Select]
if(StateSomewhere.c1.Length==0)
{
//make something useful
}
or
Code: [Select]
if(StateSomewhere.p2[1]==1)
{
//do something
}

If I make a variable like

global test = StateSomewhere.c1;

and then I call (for example) test.Length or test[2], there are no problems, but, will the changes made to test affect the original StateSomewhere.c1 variable?
« Last Edit: February 28, 2008, 07:32:36 PM by Javi-Wan Kenobi »
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: Problem with "nested" variables
« Reply #1 on: February 28, 2008, 08:05:29 PM »

it's easy:

StateSomewhere.p1 = test;
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.04 seconds with 20 queries.