• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

reusing struct variable arrays?

Status
Not open for further replies.
Level 17
Joined
Jul 17, 2011
Messages
1,864
JASS:
struct cool
integer c
endstruct 

//===============================

function  d takes nothing returns nothing 
local cool array A
local integer v 
set A[22].c = 40 
set v = A[22].c

can i just reuse this as many times as i want or do i have to allocate it?
for example i wanted to assign the old array a new value
JASS:
A[22].c = 66
after it had a value of 40 is this going to cause any issues?
 
Nope.
Struct arrays do not lose their array values(values before ".")
Its something like this in JASS(simplified)
c[A[22]] = 66
You can actually do something like this:
Cool(8192).c
which converts 8192 to a Cool value.
The local cool array one will lose its value.
Locals only works for the function they are declared.

If you want,its either use allocate/deallocate or create a Struct structure for functions(methods)
 
Status
Not open for further replies.
Top