Need help with 2 and 3 Dimentional arrays

Trithilon-V2

New Member
Reaction score
20
Guyz...i am working on a inventory system in gui.
Now i have searched the forum on this but the info i got was quite irrevelent or incomplete or was for jassers.
So any one knows of a system that helps you use 1 or more single dimentional arrays as a 2 or 3 dimentional array?
I need this to keep record of items carried by heroes on the map.
the minimun array size should be 100(units)X 5(Pages) X 6(Slots) = 3000
 

Flare

Stops copies me!
Reaction score
662
I don't think you can make multi-dimensional arrays (not really sure on exactly what they are, or how they work though)

You could set arrays 1 - 100 as first item slot, first page for each unit
101 - 200 as second item slot, first page.

So...
((Page number X Slot number) - 1) + Custom value of the unit
(or whatever way you refer to each unit)
 

Trithilon-V2

New Member
Reaction score
20
yea....what seems to ease the problem...but that would be a workaround.
I read a few posts from daelin saying e had made one such system...
So is it possible? even if it means goin in jass?
 
K

Kerberos

Guest
Yeah, there's no way (at least with the normal WE) to make an array of arrays. (Definitely not with the GUI, and if you tried JASS, it would interpret the second "array" as a variable name and scold you for using a special word where you shouldn't.)

And with (page * slot) - 1 + custom value, the second page in the first slot for a unit will yield the same thing as the first page in the second slot for the same unit. I suggest

((Slot # - 1) * 500) + ((Unit # - 1) * 5) + (Page # - 1)

or more generally, for any number of dimensions,

((V1 - 1) * (max value of V2 * max value of V3 * max value of V4...))
+ ((V2 - 1) * (max value of V3 * max value of V4...))
+ (V3 - 1) * (max value of V4 * max value of V5...)
+ etc.

So in this case, your three variables are page number, slot number, and unit number, so your options are:
(Slot-1)*500 or (Unit-1)*30 or (Page-1)*600
+ (Slot-1)*(100 or 5) or (Unit-1)*(5 or 6) or (Page-1)*(100 or 6)
+ (Slot-1) or (Unit-1) or (Page-1)

(This is assuming that your unit numbering scheme (I suggest custom values as well) begins with one and increases by one number each time.)
 

Flare

Stops copies me!
Reaction score
662
And with (page * slot) - 1 + custom value, the second page in the first slot for a unit will yield the same thing as the first page in the second slot for the same unit. I suggest

Oops, I meant to multiply by 100 :|
Code:
(((Page number X Slot number) - 1) * Max number of units) + Custom value of the unit
Custom value of the units should go from 0 to ((max number of units) - 1), to prevent overlaps
 

Trithilon-V2

New Member
Reaction score
20
wow a nice formula...but i dunno how to implement it over here....i mean, i use an array of size 100 to mark all heroes with multiple pages in inventory. I use a for loop to check if its the same unit in the array when ever the trigger fires.
And beacause my inventory system uses stacking bonuses i have decided 2 pages as the maximum limit with 6 slots in each page.
So here
So in this case, your three variables are page number, slot number, and unit number, so your options are:
(Slot-1)*500 or (Unit-1)*30 or (Page-1)*600
+ (Slot-1)*(100 or 5) or (Unit-1)*(5 or 6) or (Page-1)*(100 or 6)
+ (Slot-1) or (Unit-1) or (Page-1)
are you suggesting the result to be the array number?

Still let me give it a shot....this calls for immense testing.
Brb in a few hrs.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top