lua.wetgenes.gamecake.zone.scene.generate_uid
local uid = scene:generate_uid()
local uid = scene:generate_uid(uid)
Simple unique incremental IDs for items to be used instead of pointers, starts at 1 and goes up as items are added.
Ideally you will also need extra code for compacting these ids ( probably as an export, renumber, import cycle ) to stop them getting huge and breaking. So a save/load system which is out of scope for this code.
Generally, unless we are creating and destroying millions of items we will run out of memory way before this number gets too big.
If a uid is passed in then we will return uid+1 and continue on upwards for subsequent calls.
The point of uids is so we can refer to and lazy link items as weak values making it easy to delete an item without worrying too much about where it has been used. So instead of putting the item table inside another item table we can use a uid reference instead.
Good for serialising data as well.