Hello,
In my current game I'm working on I'm using a simple stat pannel inventory system that just uses src.contents, and I have it all equpping and everything the way I wanted with overlays. The thing I don't know how to do is save everything in the inventory (or src.contents) when the user logs out so everything will still be there when the user logs in again.
Anyone know how I might be able to do this?
Thanks in advance!
ID:157747
![]() Jan 7 2010, 9:07 am
|
|
![]() Jan 7 2010, 11:11 am
|
|
Any and all non temporary variables will be saved automatically when atom.Write() is called, including contents.
|
Spunky_Girl wrote:
Any and all non temporary variables will be saved automatically when atom.Write() is called, including contents. The code I'm using to save currently is: mob How and where would I put the atom.Write() you mentioned and how would I tell it to read it again? |
You already have it but you should not be calling Write() directly. The proper way to save/load is like so:
client Note that any variables not declared tmp will be saved automatically and so you don't need to fiddle with them (like contents and presumably your rpname variable). |
Hey, thanks, Garthor. I just merely replaced my old code with what you wrote and it worked. If I change just a few things in what I have set up it should all be fine!
|
What ive seen is that people create a skill name variable, and if it is set to 0, they dont have the skill, and if it is set to 1, they do have it.
|
Sorry for restarting an old discussion, but I tried Garthor's code he posted and it did work fine in doing everything I wanted, but as I was testing my game again I noticed that the overlays I have for armor and such on the mob are saving, but they won't come off again! I've tried MANY different things in trying to get it to work but I still can't get it. Is there something I could add or change to let me be able to still add and remove those overlays after they save?
|
This is because when you save an atom with overlays, they become merged with the icon. To get around this, you have to move the atom's overlays to a separate list then save the list (make sure the atom's overlays is also empty). After the atom loads, you can set the atom's overlays to the saved list.
|
They don't become merged with the icon, it's just that it's rather difficult to remove them from overlays across sessions, because the requirements for something being the "same" with respect to the overlays list is rather obnoxiously specific.
The best thing to do is just not save the overlays at all and reconstruct them from pertinent data afterwards. For example: obj/item/equipment |
I don't understand what the "in equipped" means in:
for(var/obj/item/equipment/E in equipped) Is it a variable that needs to be defined? And if it is, what do I define it with (i.e. var/equipped = "what goes here")? |