Map Modul for MM2
Posted: Thu Nov 27, 2014 8:42 am
This is my map module for MM2 which is thread safe.
I tested it base functionality and it works.
With it you can safe any primitive type in MM2, you can also save any other but I can't guarantee what happened than anything will cast to a pointer than and pushed back as userdata than.
primitives are:
bool, int, float, string,char
not primitives are:
functions, tables, coroutines
API(short):
The map will hold the values even after the script ended because of that use map.clear() at the end of the script(or you want to keep the values)
There is also for each function another version with a u for unsigned int e.g. map.getu(string_key).(not so tested)
The int values are 64-bit intern.
PS: e.g The LT_FUNCTION ~= LUA_TFUNCTION was kinda confusing
I tested it base functionality and it works.
With it you can safe any primitive type in MM2, you can also save any other but I can't guarantee what happened than anything will cast to a pointer than and pushed back as userdata than.
primitives are:
bool, int, float, string,char
not primitives are:
functions, tables, coroutines
API(short):
Code: Select all
-- bring a value to the map
map.set(string_key, primitive_value);
-- get a value out of the map
local value = map.get(string_key);
--check if a value in the map
local bool_var = map.has(string_key);
--clear the whole map
map.clear().
--remove a value
map.remove(string_key);
There is also for each function another version with a u for unsigned int e.g. map.getu(string_key).(not so tested)
The int values are 64-bit intern.
PS: e.g The LT_FUNCTION ~= LUA_TFUNCTION was kinda confusing