EDIT: Not looking here anymore, use it if you want, remove this thread if it buggs you
I don't like looking here every few days to see if something has to be update only to see that there isnt a single post in ages. And its not only this topic, its the whole f*ing forum...
Description
I was bothered by not being able to allocate memory on the run, so I made this library to organize the Data Table to work as possible replacement.
allocating parts of the data table (no overlapping)
includes stack
includes infinite array imitation
includes an iterator for array imitations with a fixed size
Installation
import the library, has to be below the natives
Additional Information
Speed:
The Data Table is slow, very slow. I already heard from a lot of fellow map developers that it is "evil" and should never be used.
That is, in fact, true (at least the part where it says slow). But at long as you keep it below 100.000 operations (read or write already created entries) per second you wont even feel a difference to normal variables.
Creating 100.000 new entries costs roughly 0.5 seconds, so you might want to keep big initializations splitted to multiple ticks (wait(0.0625) every 5000 entries for example) or do them on startup
Limitations:
The Data Table is limited. Very limited. After shoving 30940 string entries into it the game stops working (trigger errors on every trigger).
This also happens to all data types I tested except for reals (gui name of fixed), integers and booleans. (haven't tested much more)
However, the amount of Integers, Reals and Booleans is UNLIMITED!
Considering this, the library mainly uses integers for the internal functions. The only place where limited types are used is the "Allocator".
Whenever you initialize an "Allocator" in a new subtable (one that has never been an Allocator) 1 string is saved in the datatable.
Drawbacks
ATSL needs 1 char as separator. This should not be used or entrynames could overlap.
It is at the very top in the library, you may change to any char you dont use anyways.
You do not lose control over the whole datatable. everything not starting with the separator still belongs to you (you can even use the separator in those strings, just not as first char).
Every subtable that is created can be used like a whole new datatable (including adding more structures like arrays allocators and stacks)
How to
getting started:
Calling the function "Tables - Get New" gives you a new TablePosition.
Good job, you now have your first SubTable and can start saving values!
saving/loading
Use the string you just aquired as name in any of the "save data table value" actions/"value from data table" functions.
records
You want to save more than a single value? Globally save the name under wich you want to save each particular value.
Concatenate the name to the right side of your subtable.
example: var = load(subtable + myHero)
(load being any of the load functions, myHero being a string variable)
Adding a suffix for the type is a good idea, as mixing up always results in loading 0 or null (myHero (unit)).
arrays
There is that one particular datafield that you want to be an array?
Use "Tables - Array - Get Array Position" to get the string reproducing that array position.
stacks
First you need a subtable.
Call "Tables - Stack - Initiate at Position(subtable)" to set up the stack.
Push(subtable) and Pop(subtable) both return a string, wich is a subtable as well. The subtable returned by "Push" should be filled with all the data you want to read when you "Pop" the subtable again.
allocators
First you need a subtable
Call "Tables - Allocator - Initiate at Position" to set up the allocator.
You can now start Allocating and Recycling subtables!
Last notice:
When using data with a fast pace, allocating and deallocating a lot, do not clear the table entries, use a single allocator for every record type for a maximum chance of reusing every entry that was already initialized.
edit: uploaded version 1.0, removed a bug where reallocating a used value gave back a wrong position
fully backwardscompatible
Allocateable as integerPosition support (in case you want to use it with unit custom values)
EDIT: Not looking here anymore, use it if you want, remove this thread if it buggs you
I don't like looking here every few days to see if something has to be update only to see that there isnt a single post in ages. And its not only this topic, its the whole f*ing forum...
Description
I was bothered by not being able to allocate memory on the run, so I made this library to organize the Data Table to work as possible replacement.
Installation
import the library, has to be below the natives
Additional Information
The Data Table is slow, very slow. I already heard from a lot of fellow map developers that it is "evil" and should never be used.
That is, in fact, true (at least the part where it says slow). But at long as you keep it below 100.000 operations (read or write already created entries) per second you wont even feel a difference to normal variables.
Creating 100.000 new entries costs roughly 0.5 seconds, so you might want to keep big initializations splitted to multiple ticks (wait(0.0625) every 5000 entries for example) or do them on startup
The Data Table is limited. Very limited. After shoving 30940 string entries into it the game stops working (trigger errors on every trigger).
This also happens to all data types I tested except for reals (gui name of fixed), integers and booleans. (haven't tested much more)
However, the amount of Integers, Reals and Booleans is UNLIMITED!
Considering this, the library mainly uses integers for the internal functions. The only place where limited types are used is the "Allocator".
Whenever you initialize an "Allocator" in a new subtable (one that has never been an Allocator) 1 string is saved in the datatable.
ATSL needs 1 char as separator. This should not be used or entrynames could overlap.
It is at the very top in the library, you may change to any char you dont use anyways.
Every subtable that is created can be used like a whole new datatable (including adding more structures like arrays allocators and stacks)
How to
getting started:
Calling the function "Tables - Get New" gives you a new TablePosition.
Good job, you now have your first SubTable and can start saving values!
saving/loading
Use the string you just aquired as name in any of the "save data table value" actions/"value from data table" functions.
records
You want to save more than a single value? Globally save the name under wich you want to save each particular value.
Concatenate the name to the right side of your subtable.
example: var = load(subtable + myHero)
(load being any of the load functions, myHero being a string variable)
Adding a suffix for the type is a good idea, as mixing up always results in loading 0 or null (myHero (unit)).
arrays
There is that one particular datafield that you want to be an array?
Use "Tables - Array - Get Array Position" to get the string reproducing that array position.
stacks
First you need a subtable.
Call "Tables - Stack - Initiate at Position(subtable)" to set up the stack.
Push(subtable) and Pop(subtable) both return a string, wich is a subtable as well. The subtable returned by "Push" should be filled with all the data you want to read when you "Pop" the subtable again.
allocators
First you need a subtable
Call "Tables - Allocator - Initiate at Position" to set up the allocator.
You can now start Allocating and Recycling subtables!
Last notice:
When using data with a fast pace, allocating and deallocating a lot, do not clear the table entries, use a single allocator for every record type for a maximum chance of reusing every entry that was already initialized.
edit: uploaded version 1.0, removed a bug where reallocating a used value gave back a wrong position