Lady: making savegames easy

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lady: making savegames easy

Post by Robin »

Thanks!

Well, many people use some kind of class system in their games, especially for entities (player objects, enemies...) and the like. The problem is that if you serialise a class instance as a table and then de-serialise it, it doesn't work as expected. That's where Lady comes in. It detects class instances and generates the right code to make everything work seamlessly.
Help us help you: attach a .love.
User avatar
Snuux
Prole
Posts: 49
Joined: Sun Dec 15, 2013 10:43 am
Location: Russia, Moskow
Contact:

Re: Lady: making savegames easy

Post by Snuux »

Look cool. But if I would solve the problem, I would create an additional table. And would use this table to record the data (health, attack power, and etc).
Watch your code, and it's very cool too. Continue develop! Thanks!)
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lady: making savegames easy

Post by Robin »

Thanks.

I didn't understand what you mean in this part:
Snuux wrote:I would create an additional table. And would use this table to record the data (health, attack power, and etc).
Do you mean you would use a table instead of classes? Or use a single table instead of multiple tables to hold the state? Or something else?
Help us help you: attach a .love.
User avatar
Snuux
Prole
Posts: 49
Joined: Sun Dec 15, 2013 10:43 am
Location: Russia, Moskow
Contact:

Re: Lady: making savegames easy

Post by Snuux »

Something like this.

Code: Select all

Entity= Class('Entity')
Entity.stats = { hp = 100, dmg = 50, range = 5 }
function Entity.initialize()
  Entity.stats = loadSavedTable()
end
function Entity.save()
  saveTable(Entity.stats)
end
But now I starting understand, how your library can save my time and code...
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lady: making savegames easy

Post by Robin »

Well, it took nearly 200 lines of code, but Joints are now supported.

With the Love-Jam going on, Lady should be the perfect way to easily add a save and load feature to your jam entry!
Help us help you: attach a .love.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Lady: making savegames easy

Post by Karai17 »

A very helpful addition would be support for hump.vector (with an optional z and w param, since i use a custom vector3d lib too). Serializing vectors and then needing to reestablish their vectorness is annoying :P

Otherwise, nice lib!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lady: making savegames easy

Post by Robin »

To use hump.vector, simply register it:

Code: Select all

local lady = require 'lady'
local vector = lady.register_class(require 'hump.vector', 'vector')
Similarly for your vector3d.

Lady needs to know beforehand what kind of classes you're using, so it can do the right thing when loading a savegame.
Help us help you: attach a .love.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Lady: making savegames easy

Post by Karai17 »

Ah! I haven't looked into how this works so I didn't know it was modular. :)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
prixt
Prole
Posts: 26
Joined: Sat Sep 12, 2015 5:53 am

Re: Lady: making savegames easy

Post by prixt »

Hi I wasn't sure where to ask this, so I'm asking here.
I'm trying to use Lady for saving a roguelike map, but load_all is returning an error saying that on line 544 in lady argument #1 for function setfenv is nil. save_all works fine, I checked the savefile and everything seemed ok. How can I solve this?
User avatar
ejmr
Party member
Posts: 302
Joined: Fri Jun 01, 2012 7:45 am
Location: South Carolina, U.S.A.
Contact:

Re: Lady: making savegames easy

Post by ejmr »

setfenv() was removed in Lua 5.2. LÖVE uses LuaJIT, however, which maintains a lot of compatibility with Lua 5.1 and thus still has setfenv(). So my guess is that you are trying to run your code with a verison of Lua that no longer supports setfenv().
ejmr :: Programming and Game-Dev Blog, GitHub
南無妙法蓮華經
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests