• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗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