From that table I want to make "fast" tables, that can be accessed by triggered events.
About like so:
Code: Select all
...
entityInfo = {
entity = entity,
state = calculateSomeState(entity),
...
}
...
table.insert(gobals.entitiestable[force.name], entityInfo) -- adds one entityInfo to the global table
...
table.insert(my_fast_table[entity][entityInfo.state], entityInfo.entity) -- adds that entity to the "fast" table
...
In both cases I want to lookup to the same entry in the other table.
So my idea about this was, that all entities are not added to a sorted list (1, 2, 3...) but to a hashed-table.
The problem is then: How do I get a useful hash?
My idea for that looks currently like so:
Code: Select all
...
entityInfo = {
entity = entity,
state = calculateSomeState(entity),
...
}
entitiyInfo.hash = tostring(entitiyInfo.entity) -- entitiyInfo.hash is now something like table: 0x123e47129
...
gobals.entitiestable[force.name][entityInfo.hash] = entityInfo -- adds one entityInfo to the global table
...
my_fast_table[entity][entityInfo.state][entityInfo.hash] = entityInfo.entity -- adds that entity to the "fast" table
...