• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to make a condition that checks if something is part of an array?

Status
Not open for further replies.
Level 19
Joined
Jul 2, 2011
Messages
2,162
What programming language are you talking about?

I know in java you can just do the following function to determine if the array is populated

String Array[]={"","","","",""};
if(Array.Length()!=0){

}
 
Simple Arrays don't have such a feature.
Rect/Group have it.

To achive it you'll have to loop the Array and set a Boolean.
After the Loop check if the Boolean is true.
  • Is Part of UnitArray
    • Events
      • Unit - A unit Dies
    • Bedingungen
    • Actions
      • -------- Loop Array --------
      • Set IsIn = False
      • For each (Integer Loop) from 0 to Array_Last, do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal Array[Loop]
            • Then - Actions
              • Set IsIn = True
              • -------- Exit Loop --------
              • Set Loop = 182312320
              • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsIn Equal True
        • Then - Actions
          • -------- Do your Stuff --------
        • Else - Actions
          • -------- Do Nothing --------
Edit: I know that for Units their is allready Group, but this a easy Example which can be tested easy.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
First of all... context!
For you it might sound simple "why is this?" "how comes that?" etc, but in fact, you have no idea about how broad things can be.
There is an exception when you ask for a reason or ideas, but thats not the case.
So always explain your situation to get the right answer faster

To actually answer the question: thats impossible.
An array is a list of objects or values.
In the second case, a value can never keep track of all the arrays in existance to know if an array gontains a value with the same data.
In the case of objects, you are not so lucky either.
Even though the data might be the same, the objects could be different.
And even then, you could have an integer for every array to say in which index your object is, but if your object is found multiple times in the same array, this will fail.
So youll need an array for each array for each object. I hear design flaws... or crying performance, you may choose
 
Status
Not open for further replies.
Top