ID:151677
 
How would you approach saving inventories?

Storing items that have variables that change from item to item.
The easiest method I can think of is using the BYOND Savefile format. You can turn a savefile into a text file, encrypt that, and store it in the database.
A persistence layer of sorts. I am due to make a blog post on how you might go about making a rudimentary persistence layer from MySQL, before eventually releasing a more sophisticated library of my own.
Like Tiberath said, you could just use the already-existent savefile mechanism. Encryption being optional (maybe preferred), you might do something like this:

proc/get_save_text(mob/m)
ASSERT(m)
var/savefile/s = new
s << m
return s.ExportText()

After that, you might encrypt the result, and then you can stick it directly into your database. When you go to load, decrypt if it was encrypted and then use ImportText() to load it.
Thank you all for the ideas.
In response to Stephen001
Stephen001 wrote:
A persistence layer of sorts. I am due to make a blog post on how you might go about making a rudimentary persistence layer from MySQL, before eventually releasing a more sophisticated library of my own.

Did you ever get round to writing this blog/library?
I am aware this is an old post, however, i have recently created an inventory system using only mysql and would love to see others ideas on such a system.
In response to Tonyth
I think it's a wonderful idea.
Just sayin'
In response to DivineTraveller
DivineTraveller wrote:
I think it's a wonderful idea.
Just sayin'

I see Its pretty similar to mine actually.
I load the users contents a bit differently.

Cheers for the ref Traveller.