[GUI] Dynamic Indexing Template

This bundle is marked as director's cut. It exceeds all expectations and excels in every regard.
This template contains five different index possibilities:
- Dynamic Indexing
- Dynamic Indexing 2
- Handle Indexing (Can be used as Unit Indexer for example.)
- Handle Indexing 2 (Can be used as Unit Indexer for example.)
- Fusion of both System for channeling spell

This is a demo map for a dynamic indexing system and some other indexing systems. The systems are pretty simple and I don't need to take credits if you use it. I just made this example map since Im sick to see all those spell demo maps using ineffective indexing systems.

In the demo map should be enough documentation to understand this really simple system. But If you have still questions about the system then you are free to ask me.

Changelog:
Version 1 = Release
Version 2 = Fix / ++ Documentation
Version 3 = Added Hashtable Indexing / ++ Documentation
Version 4 = Added channeling spell example / ++ Documentation
Version 5 = Added new indexing method / ++ Documentation / ++ Optimation
Version 6 = Added handle/unit indexer method / ++ Documentation / ++ Optimation / ++ Ingame Screenshot
Version 7 (Final) = Handle Indexer Fix / changed Documentation


Hint: The examples can be used as template.

Keywords:
index, demo, dynamic, indexing, recycle, recycling, unit indexing, zZz
Contents

DynamicIndex (Map)

Reviews
7 Dec 2011 Bribe: Promoted to Director's Cut. We are recommending this template to users all the time and have many approved resources using it. 18:32, 6th Oct 2009 The_Reborn_Devil: This is really nice for GUI'ers, but can also be good for...

Moderator

M

Moderator

7 Dec 2011
Bribe: Promoted to Director's Cut. We are recommending this template to users all the time and have many approved resources using it.

18:32, 6th Oct 2009
The_Reborn_Devil:

This is really nice for GUI'ers, but can also be good for JASS'ers as well.
It is a nice method which I often use myself.
Approved and Highly Recommended.
 
you might should add some note that when using Integer A/B you have to do this:
  • Custom script: set bj_forLoopAIndexEnd = bj_forLoopAIndexEnd - 1
or that:
  • Custom script: set bj_forLoopBIndexEnd = bj_forLoopBIndexEnd - 1
cause the internal counter won't be reduced the other way

and if the last slot is empty and the current slot runs out the last slot will only be recycled after the whole thing started again
Example:
(0 means the slot is empty)
1 0
2 0
3 0
slot 1 is replaced with slot 3 and index reduced to
3 0
2 0
slot 2 will be deleted
3 0
trigger runs again
-
and just by now the third slot got removed

this might sound like a minor bug while everything is executed every 0.03 sec but imagine a trigger running every minute or a trigger running every 0.03 sec with 1000 slots

I'd recommend setting the counter variable to counter - 1 too

however I probably did not understand it fully
I'd do it like that:
 

Attachments

  • Indexing.w3x
    28.4 KB · Views: 434
Level 14
Joined
Jan 15, 2007
Messages
349
D4RK_G4ND4LF said:
you might should add some note that when using Integer A/B you have to do this[...]

Ok sure...

D4RK_G4ND4LF said:
I'd recommend setting the counter variable to counter - 1 too

oO I have forgot to do this... will be added ... seems like I was yesterday just to tired...

Edit: Ok new version is up with those fixes...

Edit2:

Aspard said:
But I guess for just beggining GUI coders :)
And those "begginers" will never try look for this system before creating and uploading unefficient spells. ;(

Sure they won't but next time if a guy is using an ineffective indexing system I'll just link to this system... ;)
 
Level 17
Joined
Mar 17, 2009
Messages
1,350
D4RK_G4ND4LF said:
that's genius!

we should make some text containing all the usual noob mistakes and just copy and paste them :grin:
Duh... why do you think I've worked my ass on the Essentials Tutorial? :p

----

And well the best thing with this is that unlike tutorials, it's there for you to use... :) and it's very simple dynamic indexing.

I've seen other methods, and even though some are similar to this, they were explained in such a complicated manner that it's impossible to know what's going on...

So I definitely advice using this =)
 
Level 6
Joined
Jun 15, 2008
Messages
175
I've found a "bug". If you copy paste the trigger into a new map, the integer SPELL_LOOP is not copied as a variable correctly, it is never used besides in an array. I don't know if this could be fixed by setting it to something somewhere, or you just have to mention it. I may cause confusion to rookies :)
 
Level 14
Joined
Jan 15, 2007
Messages
349
Because "Paladons Indexing System" (if you really want to call it so) isn't dynamic at all.

Ok I'll describe you what "Paladons Indexing System" does:
After really every object in an/a array/loop is inactive the whole indexing get reseted and it start from zero. The bad thing about that is that this way is pretty ineffective. Just imagine that you have one spell and you cast it like 40 times in a row. Not at the same time but so that like short before the spell really ends you begin to cast the spell once again. So it will loop through the array also if objects are inactive. Just after really every object is inactive the whole indexing thing get reseted. I hope understood what I mean.

Now I describe what this dynamic indexing template does:
Well this template is an effective dynamic indexing system. Instead of looping through the whole array until the indexing get reseted it recycle the index instantly. That means if you cast one spell 40 times in a row (like in the example I told you in the description of "Paladons Indexing System"). It will loop really just through those indexes that are active. That's a big performance difference to "Paladons Indexing System".


I also added in the last version an example that shows how easy it is with using this template to make a MUI channeling spell in GUI. There are many possibilities to use this template to make your spell MUI and effective at the same time.

But in the end you have to decide what system you are using. This template is just a help. How I said in the description it's not needed to give me credits if you use it since everybody should know this simple indexing stuff.
 
Level 10
Joined
Feb 20, 2008
Messages
448
Because "Paladons Indexing System" (if you really want to call it so) isn't dynamic at all.

Ok I'll describe you what "Paladons Indexing System" does:
After really every object in an/a array/loop is inactive the whole indexing get reseted and it start from zero. The bad thing about that is that this way is pretty ineffective. Just imagine that you have one spell and you cast it like 40 times in a row. Not at the same time but so that like short before the spell really ends you begin to cast the spell once again. So it will loop through the array also if objects are inactive. Just after really every object is inactive the whole indexing thing get reseted. I hope understood what I mean.

Now I describe what this dynamic indexing template does:
Well this template is an effective dynamic indexing system. Instead of looping through the whole array until the indexing get reseted it recycle the index instantly. That means if you cast one spell 40 times in a row (like in the example I told you in the description of "Paladons Indexing System"). It will loop really just through those indexes that are active. That's a big performance difference to "Paladons Indexing System".


I also added in the last version an example that shows how easy it is with using this template to make a MUI channeling spell in GUI. There are many possibilities to use this template to make your spell MUI and effective at the same time.

But in the end you have to decide what system you are using. This template is just a help. How I said in the description it's not needed to give me credits if you use it since everybody should know this simple indexing stuff.


now i understand, you are right, i experiment it yesterday, the normal paladon require spell cooldown or glitch can happen, instead urs can be spam :p

indeed this type of coding very useful to make powerful GUI system but i guess for a spell that only being cast by 1 hero is kinda wont be useful for me, but since im doing some request i have to use it :p i cannot use unefficient thing :D + rep u deserve for this!! i will use this thing often for next spell i will make :p

i guess i will use your system to make my Own Stunned System ^^

but i didnt figured out how ur system is shorter or e-zier,
 
Useful for both GUIers and JASSers :p

Why it's useful for vJASSers:
When you make a struct extend an array, you need to write your own methods for allocation/deallocation (Not totally required, but anyways, if you need the struct to have instances, you need to add these, but there are some exceptions (A struct based on UnitIndexer Ids for example))
 
Hanky - Is 'new' method really more "user friendly"? :p
6 vars instead of 3 (we can omit TempInt one in case it's just for simplicity) -> more variables usually mean more stuff to get/think about, thus.. more question to ask for :S.

In my opinion you should explain further the first one, although to be honest there is nothing to explain at all.. After coping (yeah just CnP) the system and implementing into random spell (basing on template) it's harder not to learn the system rather than actually learn it.

3 more integers, require more memory too ^^ 3 * 32 = 96 bits.
 
Level 14
Joined
Jan 15, 2007
Messages
349
Yes I know... and it's just another method... nothing more ;)
(And btw we are speaking about GUI+Speed(Memory use)? You are joking.)

And yes I think the second method is easier to understand than the first one. But that's just my opinion. You can still use the first method.

And if you ask me a template is better than a tutorial since you have example code from which you can learn. At least this is how I learn new programming stuff and not reading boring tutorials. :D
 
And if you ask me a template is better than a tutorial since you have example code from which you can learn. At least this is how I learn new programming stuff and not reading boring tutorials. :D
I've never said the tutorial is better, furthermore, I'm pretty sure most people out there prefer templates (I'm in ;P) too. Anyways good job except.. variable names are just too short <joke :p>
 

Deleted member 177737

D

Deleted member 177737

This might sound stupid, but what does this even do...?
 

Deleted member 177737

D

Deleted member 177737

This is a template that shows GUI Users how to do Dynamic Indexing so that they can make their spells and systems MUI.

So do you really need to use this or can you just not if your stuff is for one person only?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
The "static" indexing doesn't remove expired instances. I loops through all indexes, and checks a boolean to see if the instance is expired or not.

If there are three instances running, 1, 2 and 3, and the second expires, the indexing will still loop through 1 to 3. The max loop index (3 in this case) is only reset when all instances have expired.

The "dynamic" indexing removes expired indexes immediately. If there are three instances running, 1, 2 and 3, and the second expires, then data from index 3 will be written to index 2, and max index will be set to 2. The indexing only loops from 1 to 2.
 
Top