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: Array question  (Read 3216 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 question
« on: July 24, 2012, 10:12:38 PM »

Hi

Is there some way to find specified value in array?
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Array question
« Reply #1 on: July 25, 2012, 09:54:48 AM »

Code: WME Script
  1. var A = new Array (300, 200, 100);
  2. const Value = 100;
  3. var IsValuePresent = false;
  4.  
  5. for (var i=0; i<A.Length; i=i+1)
  6.   if (A[i] == Value) IsValuePresent = true;
  7.  
  8. if (IsValuePresent)
  9. {
  10.  //do something
  11. }
  12.  
« Last Edit: July 25, 2012, 09:57:49 AM by 2.0 »
Logged

hubertMichael

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

Yes I do like that but I was curious if there is one command for this
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Array question
« Reply #3 on: July 25, 2012, 07:54:34 PM »

Sad to say, but the other way is impossible in WME.
But - also - you may create you own function (or method), based on usual algorytm, that will search in array and will return needed value.

Yes I do like that but I was curious if there is one command for this
Logged

hubertMichael

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

and that's true also :) I'll do like that :)

Thank You
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula
 

Page created in 0.045 seconds with 21 queries.