Hi, Im fairly new to ruby, and as an exercise of what i’ve learned and
an attempt to further understand ruby, i have decided to create a text
based RPG. I’ve been able to get pretty far with virtually no trouble,
but i have ran into a problem. I am having some trouble with the save
mechanism. the way it works is that it only saves the state of the areas
that you have the ability to travel to. but in certain areas, events are
triggered based on objects in the your inventory/environments. the
trouble i’ve been having is if you save once you’re able to travel to
the areas, but exit the game before the events are triggered, when you
get back on, the game doesnt recognize the objects as being present and
as a result the events that should be triggered arent triggered. I’m
thinking that when it saves, it saves the object with a specific
address, but when the game loads, it loads expecting a new/different
address and doesnt recognize the old/saved address. but thats just a
guess, im not sure if thats actually whats going on. right now, im using
marshal.dump to save and marshal.load to load. would anyone have any
thoughts on this?
Your style to write this confuses me.
Can you use paragraphs or newlines please?
And properly capitalize after a sentence was finished?
It makes it so much easier to actually understand what is going on …
As for your question, I don’t follow. What kind of text RPG is that?
Did you write this yourself?
And if you did, why can’t you store the state?
Sorry, but I am just confused…
On 05/09/2012 06:40 PM, Zachary Pearson wrote:
as a result the events that should be triggered arent triggered. I’m
thinking that when it saves, it saves the object with a specific
address, but when the game loads, it loads expecting a new/different
address and doesnt recognize the old/saved address. but thats just a
guess, im not sure if thats actually whats going on. right now, im using
marshal.dump to save and marshal.load to load. would anyone have any
thoughts on this?
It seems like you need to check the player’s inventory and the
environment when you load the player, in order to fire the events you
are expecting.
I don’t understand what you mean by “address”.
-Justin
I would not use marshall to do this, specifically because, as you say,
it makes it hard to keep track of transient state. Instead, spend some
time implementing a serialize/deserialize method for each of your game
objects (using json, for instance), at which point you will have very
precise control over what aspects of your world get loaded and saved,
and what setup code you need to run when importing a saved state. If
you post some code I could give you more specific suggestions.
martin