The Daily Click ::. Forums ::. Klik Coding Help ::. New member's 2 questions, please help kind Klikkers
 

Post Reply  Post Oekaki 
 

Posted By Message

Dawnbringer



Registered
  03/09/2010
Points
  1
3rd September, 2010 at 19:07:46 -

Greetings noble Klikkers!

How do I save/load duplicated objects? They all have different positions, alterable values, alterable strings and I want all of them to be stored of course. I know how to save/load one object and it's values, but if there are duplicates, will all of them have the same values after saving?

I joined the site today, so please go on me easy for asking such a noob question. I recently stumbled upon this site and it turned out to be awsome. Couldn't avoid reading tons of the articles for several days. I'm desperately trying to increase my knowledge in MMFD2 for I have Big Game Fever (which noob doesn't?). I just familiarized myself with INI, spread value function, but can't figure out, how the ini object saves the duplicated objects, each with different alterable value Z (let's say it is the spreaded value).

The second noob problem: I have some active objects that would need more than a hundred values (yes, complex game is in progress, caused by BigGameFever) but there are only 26 alterable values and a few strings per object. Shall I store those 100+ values (for example) in an array then? Currently I store them in 5 active objects which are overlapping each other to have some sort of link between them and only the first is visible. Each of them have a different qualifier (the visible 0 and the storing active objects 5,7,8,9) because there are many clones of each of them. Not sure if it was clear, so an example: if certain conditions are met with an object containing qualifier 7, then do some actions with that specific object with qualifier 7 AND with some of the remaining overlapping objects as well (but not with those 0,5,7,8,9 objects that do not overlap these objects). How could I do this if these objects' alterable values would go into an array? Can't think of a way but there have to be better options than having 5 active objects to store values for the main visible (0) object.

Hopefully I managed to explain my problem. My apologies if my english isn't perfect, patiently waiting for your answer dear Klikker.

Greetings from Hungary!

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
3rd September, 2010 at 19:57:07 -

I've done a little save-game example for you. It's a little complicated, but I'll explain why I've done it the way I have.

It's a good idea to stop relying on INI files to save game data. They're limited in the way they're structured and not really ideal for storing actual game data. They're great for things such as game/application settings - but other than that there isn't much use for them. It's much better to develop your own saving system as you can tailor it specifically to your game and make it do whatever you need doing (downside is that it's a little more complicated).

What I would do with duplicates is assign them all an ID number, at the start of the game, which is unique to each duplicate. I've done this using "spread 0 on alterable value A" at the start of the frame. One object will have a value of 0, another will have 1, another will have 2 and so on. This way you can treat each object as a different object, rather than just a duplicate.

In my example file I have 5 duplicate objects. Value A stores each objects ID number. Value B stores a value which you can set via an edit box for each object. You can select an object by clicking it (the selected object becomes slightly transparent) and you can move the selected object by clicking anywhere on the play-field. You can change Value B of the selected object in the edit box (must be a numerical value).

What I want to do then is save Value B, the X co-ordinate and the Y co-ordinate of each value. For fun, I want to also save the ID number of the object that is currently selected (so when the game loads the object I selected is still selected).

I decided that my save-game file will look like this:

[ID of selected object]
[X coord],[Y coord],[Value B]
[X coord],[Y coord],[Value B]
[X coord],[Y coord],[Value B]
[X coord],[Y coord],[Value B]
[X coord],[Y coord],[Value B]

So when the game starts I can set the selected object to whatever is on the first line. I can then loop through the other lines to retrieve the data for each individual active object. You may also want to store the ID number of the object, but in my case that isn't needed as the list is ordered by the ID number so it's easy to work out. The important thing here is that I've used String Parser to retrieve the data in between the commas.

Regarding your second question, you could also use String Parser to allow you to store more values per object. You can store the values in the alterable string. For example alterable string A could contain "32,56,65,34" - you can then parse that to retrieve the 4 different values. If you'd like an example of that then let me know.

Save game example: http://www.create-games.com/uploads/flava/SaveGameExample.zip

Edited by Flava

 
This is a signature. Have this one on me.

Rick Shaw



Registered
  30/04/2008
Points
  158
17th September, 2010 at 22:47:17 -

This is minor but related to your second question... I don't know for sure but I thought objects could have more than 26 alt values. I know that global variables go from A to Z, then start with AA, AB, AC etc... Even unto BA, BB, BC, etc. I haven't tried pushing the objects' values that far though.

For saving your values, would frame save state work for you? Under the storyboard object, you can save / load frame positions. This is something I'm playing with right now, but it isn't perfect (for me.)

 
n/a
   

Post Reply



 



Advertisement

Worth A Click