• 🏆 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!

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
539
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
539
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