The Daily Click ::. Forums ::. Klik Coding Help ::. Saving more than one array to a file?
 

Post Reply  Post Oekaki 
 

Posted By Message

Nillo



Registered
  19/10/2003
Points
  151

Has Donated, Thank You!
7th October, 2008 at 20:09:58 -

For the project I'm working on, I have some data that I need to store in arrays. I also need to save and load it to/from an external file, but the Array object can only save one array. If I put all my data in a single array it's going to get really messy and I'll probably waste a lot of memory, because some of the data needs an X value in the thousands to work, while others don't need that much at all. Is it possible to save more than one array to the same file? If not, what solution to this problem would you suggest?

 
n/a

aphant



Registered
  18/05/2008
Points
  1242
7th October, 2008 at 21:32:19 -

Try using a second Array object.

 

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
7th October, 2008 at 21:37:13 -

you can save a new array by giving it a new name...

or alternatively just use another page, you know. Make it a 3d array.

 
.

Nillo



Registered
  19/10/2003
Points
  151

Has Donated, Thank You!
8th October, 2008 at 05:34:57 -

I know that I can have more than one array in the game by creating another Array object. The problem arises when I want to save all the arrays to an external file. As far as I know, this is impossible.

And yeah, I could use a 3D array, but as I said it's an inefficient use of memory. A 5000x100x10 array for example needs 18 megabytes. If I divide it into one 5000x20 array, two 1000x100 array, etc, the required disk space would dive to a fraction of that. Also it's a lot easier for me to work with it when each array only has the relevant data in it, like, one array called "combattext" and another called "plotscript" and so on.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
8th October, 2008 at 06:18:12 -

have you considered using dynamic arrays, like the built in MMF ones? They will not define items in your array until you call them. So even if you create a 10000x10000x10000 3d array, it will only be as large as the elements you load into it. This is because they are stored as simple linked lists.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
8th October, 2008 at 06:34:09 -

Use AssArrays they're much more efficient and customizable.

If you want it:
http://mmfwiki.erathean.com/index.php/AssArray_Object

Image Edited by the Author.

 
lol

-Adam McMillan-

Mr Incredibubble

Registered
  15/09/2008
Points
  198

Wii Owner
8th October, 2008 at 09:06:12 -

If your feeling lazy, you can just use ini files using seperate groups. But that would only be practical if the data your handling isn't that complicated.

 
Image

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
8th October, 2008 at 10:58:54 -


Originally Posted by Adam McMillan
If your feeling lazy, you can just use ini files using seperate groups. But that would only be practical if the data your handling isn't that complicated.


I don't know if this is the case or not, but if he's working with a level editor, then an INI might actually be slightly more inefficient based on how well you use it.
And again, the idea of a 3D array is great if he's using a level editor, all the way up until you consider that maybe the varying degree's of the array might actually be holding values for objects within the array. So like Object X = X, Y = Y, Z = Type.

You could always use string parser to save more information into one position in an array.

Image Edited by the Author.

 
http://www.facebook.com/truediamondgame

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
8th October, 2008 at 12:00:05 -

Or you could just use AssArray to keep things simple

 
lol

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
8th October, 2008 at 17:19:26 -


Originally Posted by Adam Phant
Try using a second Array object.



I wouldn't. I once had a game that used 2 array objects and MMF would swap values between the arrays at random in a glitchy, bone-crushing, heart-breaking kind of way. Do what Andy says, and have your game use one array and when it comes time to save and load use different filenames to do it.

Image Edited by the Author.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Nillo



Registered
  19/10/2003
Points
  151

Has Donated, Thank You!
8th October, 2008 at 23:21:05 -


Originally Posted by Pixelthief
have you considered using dynamic arrays, like the built in MMF ones? They will not define items in your array until you call them. So even if you create a 10000x10000x10000 3d array, it will only be as large as the elements you load into it. This is because they are stored as simple linked lists.


This sounds very nice. I have no idea how a dynamic array works though. Is it the same thing as the Array object but with a bunch of extra functions and the efficient storage method you mentioned? Can I just replace all my old Array events with their dynamic array equivalents, and save disk space?

 
n/a
   

Post Reply



 



Advertisement

Worth A Click