Arrays and MUI

W!†A_cRaft

Ultra Cool Member
Reaction score
28
How do they actually function, i mean i know what an array is i know what they represent i know all that kind of stuff but i do not know how should i use them to make things happen the way i want them.

I am currently using Hashtables binding things to timers through JASS and that allows me to use them in other functions as locals making things MUI, but there are certain problems that i cannot overcome, i posted one of them in JASS section few minutes ago.

Also since people claim it is better to use arrays i am wondering why and how? How to replace hashtable functions with arrasy etc.
 

crazyfanatic

New Member
Reaction score
20
the array is an extention of a variable, and makes life easier than making much variables. To use it for MUI you can simply set the variable with array (always integer number) to the player number of any player. As long as each player has 1 way to trigger the variable settings, you wont need to add more actions.
 

Moridin

Snow Leopard
Reaction score
144
^ What crazyfanatic described is MPI unless I misread something.

How to have MUI using arrays:

If you have the necessary variables as arrays of a certain size (something like 50 should be enough, as more than 50 units casting an ability at the same time is almost impossible under normal circumstances)

...and along with those arrays an integer variable that acts as a counter, you can use these to enable MUI.

Basically, when you imprint the necessary values needed for a spell into the variable arrays, the location of the array (array [LOCATION]) is defined by the counter integer variable, which keeps cycling from 1 to 50 and then back to 1 and so on.

This allows you to store 50(or whatever limit) sets of ability values that are needed for a cast....which would in turn allow for 50 casted abilities without one value overwriting the past values.

I hope my explanation was somewhat clear. In my opinion hashtables are easier to use than arrays to enable MUI and are also more powerful in certain ways. However, I'm pretty sure arrays are faster for the engine than hashtables.

If you want an example of array MUI, I'm pretty sure any of the spells made by Glenphir in his spell request thread use them, as his hashtable functions are bugged for some reason.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
okay about that 50 variable arrays, but lets say i need caster/target/damage/dummy/position and few more thigns stored, i need to create a variable for each of those things? than get the date by indexing in the For Integer A loop 1 -50?

Also how to make them in JASS?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This is where vJASS makes things much easier...

For this, you only need to store one thing, and that's a struct.
But, in that struct you can store as many values as you want...

I'd suggest you read up on some v/JASS tutorials ;)
 

Moridin

Snow Leopard
Reaction score
144
i need to create a variable for each of those things?

Pretty much. This is why I find hashtables a bit more efficient in GUI. Also JASS is an obvious solution here...but there I can't help you (I don't know a hint of JASS).
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
i am familiar with structs, but why would i store strcuts into arrays than if i can store everything in a struct i dotn need arrays, i only need to store 1 struct per instance. However i do not know how to store structs :D
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
you cannot use structs in GUI nor in vJass

structs are only usable in vJass
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
ye but i dont know how to use them in jass :D dont know how to code them
they are a new type of "variable" but what are their options/methods....that i do not know
 

Rushhour

New Member
Reaction score
46
Structs are no magically new handle or whatever you might think.
They do the "indexing" for you. When Jass Helpers compiles the struct it turns all the variables inside the struct to arrays. The index for these arrays is set when the struct is created/allocated and is always unique (you will never have more than 8100 instances running the same time ^^ )

You also can use static members (variables,methods) which behave like "normal" (struct)global variables/normal functions.
As far as I know you can also have normal non-static arrays inside a struct, which are compiled like GUI- pseuda 2D-arrays.

But I haven't used structs myself, I think it's not worth the effort if I only need 2 instances of a function running the same time, so I'm not sure what else you might be able to do but spells. Read the Jass Helper manual or one of those thousand tutorials.
(e.g.: http://clanbom.com/forum/viewtopic.php?f=52&t=421&sid=32035eaaa0e482c74b8f5c873bc17c2b)
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
I am not familiar with these static/non-static members, I am somewhat new to JASS, i know what a struct is, by definition but the only use i see for it is making few variables into a single variable, i know the struct has it's own function (they are called methods correct?) and that it can have other functions in it, but i do not know anything else, including how to make one.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top