Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Array problem  (Read 3261 times)

0 Members and 1 Guest are viewing this topic.

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Array problem
« on: July 12, 2012, 01:45:39 AM »

Hi

In my base.inc I have declaration of my array:

Code: [Select]
global techAv = new Array();

techAv[0] = 0;
techAv[1] = 2;

First scene's scene_init.script add to my array third value.
Second scene's scene_init.script wants to read my array and here I got problem. There is no third value added by first scene's scene_init.script. This is because both scene's scene_init.script (first and second) has the line
Code: [Select]
#include "scripts\base.inc" and everytime when this line is executing my array has reset by it's declaration in base.inc. I've tried moving declaration of my array to game.script but then when I want do something with my array in scene_init.script debugger says that my array is not defined. I know it must be simple solution but I can't find it. Help :)

And sorry my english, still learning :)
« Last Edit: July 12, 2012, 02:03:00 AM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Array problem
« Reply #1 on: July 12, 2012, 07:24:18 AM »

You should use in your base.inc:

Code: WME Script
  1. global techAv;
  2. if (techAv.Length <= 0)
  3. {
  4. techAv= new Array();
  5.  
  6. techAv[0] = 0;
  7. techAv[1] = 2;
  8. }

So the array is set only if dos not exist and not everytime base.inc is loaded.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Array problem
« Reply #2 on: July 12, 2012, 07:27:41 PM »

I knew it must be simple :) Now it's working :)

Thank You :)
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Array problem
« Reply #3 on: July 13, 2012, 08:01:41 AM »

Instead of "if (techAv.Length <= 0)" better use "if (techAv != null)". Or even better only leave the declaration in base.inc (global techAv;) and create and fill the array in game.script.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: Array problem
« Reply #4 on: July 14, 2012, 11:32:21 AM »

Thank you :)

You know... in Poland we have saying:

"darkest under the lamp" :D
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula
 

Page created in 0.281 seconds with 24 queries.