• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

Empty Array

Status
Not open for further replies.
Level 12
Joined
Mar 24, 2011
Messages
1,082
Hello

This question is a mess between GUI and JASS. I am using GUI with custom scripts inbetween lines when needed.

  • Set TempUnitGroup = units in range of point matching unit has ability;
  • Set TempInteger = -1;
  • Unit Group - Pick all units in TempUnitGroup
    • Loop
      • Set TempInteger = TempInteger + 1
      • Set ArrayedInteger[TempInteger] = Level of ability for picked unit
  • BiggestLevel = ArrayedInteger[0]
  • If TempInteger > 1
    • Loop for Index 0 to TempInteger
      • Set BiggestLevel = Math - Get Max (BiggestLevel, ArrayedInteger[Index+1])
  • Use BiggestLevel

I have this arrayed integer which will store level of ability for a unit I need only for a single loop and thought of making it local

So, I tried making:
  • Custom script: set udg_TempInt = CountUnitsInGroup(udg_TempUnitGroup)
  • Custom script: local integer ArrayedInteger[udg_TempInteger]

Which will get populated inside the loop, but I get an error


Long story short: I want to turn udg_ArrayedVariable[] into a local array of integers, but as I suspect this is impossible/not the correct way.
I suspect that the error occurs because I am required to give a value to the variable ? How wrong am I ?
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Forgot to mention the error is: Expected 'endif'
on this line:
JASS:
  local integer LevelMax[udg_TempInt]

Edit// wops didn't see that answer :p

So something like... wait... isn't udg_TempInt a valid array size ??
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
544
Yes you can use local arrays...
It's just that all arrays in warcraft 3 have the same size so you dont need to specify it.
JASS:
local integer array x

Also, you first have to declare all locals and then you're allowed to write statements.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
JASS:
local integer array x
Also, you first have to declare all locals and then you're allowed to write statements.
That worked. Still... I do not want it there but deep inside a nested if-then-else block...

Yes you can use local arrays...
It's just that all arrays in warcraft 3 have the same size so you don't need to specify it.
Huh, when you are creating globals (udg_) variables with the variable editor some can be expanded during runtime but other are limited to what you set the array size...
Still I do not know how the engine works and if it allows you to use only the user defined array size of the later ones but creates them up to 2^13...
 
Last edited:

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
544
So if I use a local array I don't need to define a size, but if I want a global array I need to?

Seems like I learned a little from this as well.

global arrays also have the same size. the size you input in the gui editor just says how many elements are initalized.
Basically a loop from 0 to your value and set array[index] = yourvalue.
I think most of the time thats pretty useless as arrays have a default value of 0/0.0/false/null.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Ok guys, Tnx +rep both of you.
I converted it to custom script and now I understand what was the issue.

JASS:
ThreadSolved = True;
void Thread()
{
  If((AnybodyAddSomeThing == false) && (ThreadSolved == true))
  {
     CloseThread();
  }
}
 
Last edited:
Status
Not open for further replies.
Top