lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


yeah, it looks like for now, I am going to have to rely on my file system for the larger amounts of data.  I guess I would need to do this anyway if I wanted to make sure that a server/computer crash did not result in the loss of all the data that had been accumulated during that session.

Zach Dwiel

On 2/5/07, Robert Raschke <rrlua@tombob.com> wrote:
Zach wrote:
> Thanks for the info.  I got it working, but it only works for non-table
> values.  Even if I run:
>
> table = {}
> stable.set("table", table)
> print("table: ", stable.get("table"))
>
> it prints "table: nil", if I replace {} with 5 it prints "table: 5".  Is
> this something to do with the garbage collection, or something else
> entirely?

How timely a question, I just ran into the same thing.  It looks like
the stable implementation cannot share reference type values at all.

The way it works, is that the child state creates a holding table in
the parent state (or makes use of an already exsiting holding table).
This table will receive, via simple assignment, any values passed in
stable.set().  Since it is simple assignment, passing a table to
stable.set () will store the childs table reference in the parents
table.  Any subsequent stable.get() in a different child will reveice
a non-sensible table reference.

Short of implementing a clone operation, I can't really see a simple
way around this.  I will work around this by storing simple entities,
no tables.

--
r dot raschke at tombob dot com