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

[JASS] takes integer array

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hello people,,

I have heard about a function taking an array is impossible,,
But with some new type, it would be,
Now how would i properly use it? I have got type integerarray extends integer array [10]

How can i convert an 'integer array' to an 'integerarray' ? And vice versa.

Or is this not possible?

Thanks

-Yixx,,-
 
Level 6
Joined
Oct 4, 2008
Messages
263
however, you could create a struct type with an integer array member.

JASS:
struct intarray
integer array[XYZ] i
endstruct
 
An example:

JASS:
type intarr extends integer array [10] // create a dynamic array with a maximum of 10 array slots

function GetArrayIndex takes intarr arr, integer i returns integer
    return intarr[i]
endfunction
As you should be able to see from that, dynamic arrays behave exactly the same as normal arrays except they have a limit (the number in brackets when you declare it). Oh, and they have to be created like structs before you can use them. Like this:
JASS:
local intarr arr = intarr.create() //create an instance of intarr
//do stuff
 
Status
Not open for further replies.
Top