Ruby "Save Game" function

Hello!

I am currently working on a text-based RPG and I wanted to implement a
function that allowed the user to save their game at any point, so that
it could be resumed later. Of course, this would need to be complimented
by a load function that would resume the game at that previous state.

Anybody know how I would do this? :slight_smile:

Thank you in advance!

-SS

Michael B. wrote:

I am currently working on a text-based RPG and I wanted to implement a
function that allowed the user to save their game at any point, so that
it could be resumed later. Of course, this would need to be complimented
by a load function that would resume the game at that previous state.

For starters, I’d suggest looking at PStore and YAML::Store.

PStore:

http://ruby-doc.org/stdlib/libdoc/pstore/rdoc/classes/PStore.html

YAML::Store exmaple:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113207

PStore and YAML::Store are essentially equivalent in functionality,
the difference is PStore saves objects in Ruby’s binary marshal
format, whereas YAML::Store saves objects in human-readable YAML
text format. And the trade-off is that YAML is slower than marshal.

Further possibilities for key/value stores with Ruby:

http://www.engineyard.com/blog/2009/key-value-stores-in-ruby/
http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-2-tokyo-cabinet/
http://www.engineyard.com/blog/2009/cassandra-and-ruby-a-love-affair/
http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-4-to-redis-or-not-to-redis/
http://www.engineyard.com/blog/2009/mongodb-a-light-in-the-darkness-key-value-stores-part-5/
http://www.engineyard.com/blog/2009/key-value-stores-in-ruby-the-wrap-up/

Hope this helps,

Bill

Bill,

Thank you for the links! It’s still a lot to chew on, but I’ll try to
figure it all out. :stuck_out_tongue:

Best Regards,

-SS

On 16 Feb., 11:52, Michael B. [email protected] wrote:

Bill,

Thank you for the links! It’s still a lot to chew on, but I’ll try to
figure it all out. :stuck_out_tongue:

Best Regards,

-SS

Posted viahttp://www.ruby-forum.com/.

Hi,

you could try out MongoDB or CouchDB as well.

http://www.mongodb.org/
http://couchdb.apache.org/

Michael B. wrote:

Hello!

I am currently working on a text-based RPG and I wanted to implement a
function that allowed the user to save their game at any point, so that
it could be resumed later. Of course, this would need to be complimented
by a load function that would resume the game at that previous state.

Anybody know how I would do this? :slight_smile:

Thank you in advance!

-SS

May I suggest “sequel + sqlite”? http://sequel.rubyforge.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs