[GUI Interface] UnitIndexing

SerraAvenger

Cuz I can
Reaction score
234
A simplistic interface for unit indexing systems. Will be expanded once there are more systems with more features.

Please don't use any indexing systems directly, always use an appropriate interface!


API
UnitGetIndex( u ) -> int, change this to return the value of a function from a unit indexer. Should return a unique index to use with arrays and similar stuff.
UnitGetByIndex( i ) -> unit, change this to return the unit associated with an index. u == UnitGetByIndex( UnitGetIndex( u ) ) should always be true.
CustomValueGet() -> int, change this to return the value of a function from a unit indexer. Should return a unique index to use with the GetUnitCustomValue function.


Please also see...
SerraUnitIndexing, a unit indexer


How to use this?
Always use this with an appropriate unit indexer. A good example is SerraUnitIndexing, which was designed to be used with this.
When you have this library imported, change it's library id to "saii". Then import any other library that requires this library.

- Using the SerraUnitIndexing library
First, import the SerraUnitIndexing library.
Then, change the SerraUnitIndexing library id to "saui" (serra avenger unit indexing).
Then, import this library, and you're done.

- Using another library
First, import the library you want to use.
Then, search that library's API for the functions that do what the functions in this interface do.
Import this library.
Go to the functions from this library, go to the "actions" definition and look for a "return (val)" statement. Change the value in that return statement to the function you want to use, and pass all parameters accordingly.
You might want to go into raw mode (by pressing ctrl+d) in order to change the functions, since many galaxy-oriented programmers are always in raw mode.

From then on, simply use "Get Unique Unit Index" and "Allocate Unique Custom Value" in the GUI (or the functions from above if you're in raw mode).

FAQ
Q< I put this into my map, but nothing happened?
A> This is just an interface. It doesn't do anything itself. In order for it to do something, you need a piece of software that does it. Then you must tell the interface to use the software.

Q< Why use this then?
A> Imagine you're using PerfectUnitIndexing (without any interface). You import a library that uses AutoIndexer (without any interface). Those libraries conflict, you can't use them.
Now, Imagine you're using PerfectUnitIndexing (without any interface). You see that AutoIndexer is a lot better. Have fun searching your code for every appereance of "PerfectUnitIndexing" and changing it to the correct "AutoIndexer" function!
SOLUTION: Don't use these libraries directly. Instead, only use an interface. Due to using the functions of the interface only, external code (that's using the same interface) will always work in your map no matter which system you use in the background. If you want to change the system, just tell the interface to use the new system - and your code will still work!

Q< I tried using this with SUI. I Imported SUI, then I imported this, but the map doesn't compile/save/work?!?!
A> Did you change the library id of SUI to "saui" (serra avenger unit indexer)?

Q< What is a library id?
A> It is a unique identifier used for making code harder to import, harder to use in galaxy, and just making your code look stupid. It's one of Blizzard's inventions.

Q< I meant, how do I change it?
A> Right click on your library, go to "Library" in the context menu, and click on "Change Libary Id" or something. A window should open where you'd click a check box, select the upper line (where you don't generate a random hex number) and enter 4 characters. For SUI, it should be saui. For the SerraAvenger TeamLib, satm. If it is needed, it should say it in the thread.

Changelog
6/18/2010 - Added support for UnitGetByIndex functions!
 

Attachments

  • UnitIndexing.SC2Lib
    4.6 KB · Views: 353
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