Skip to content

Instantly share code, notes, and snippets.

@dgfitch
Created April 12, 2009 05:10
Show Gist options
  • Save dgfitch/93872 to your computer and use it in GitHub Desktop.
Save dgfitch/93872 to your computer and use it in GitHub Desktop.
-- So we have two problems with serialization.
-- ONE: The objects.collection looks like this:
{
1 = {
x = 30,
y = 50,
type = {
-- this is a reference to objects.node or objects.arc or whatever, a
-- table containing its OWN information that we don't want to duplicate
},
},
-- etc.
}
-- Which means we need to have a transform on object instance's type when saving and loading.
--
-- That's not too scary. This next one is a bit tougher, though.
-- TWO: An arc looks like this:
{
segments = 4,
head = { },
tail = { },
-- where both head and tail are references to node instances, stored
-- elsewhere in the objects.collection.
}
-- So now we have to either keep track of things that have been already
-- serialized (difficult since lua does not appear to expose any kind of hash
-- for tables or references) or transform the head and tail into the correct
-- index in objects.collection at save, and back again on load.
--
-- Ideas?
-- vim:ft=lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment