Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Saving Data from an array to a savegame file

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 14th Aug 2010 00:47
Ok i have a small problem, i have managed to make my game save the player position and screen resolution, but i have a problem i can't get figure out how to save the player inventory..

this is how i make my inventory...


and this is my save file



I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th Aug 2010 03:16
Have you got the Matrix1 plugins? If not, why not? :p There is a command that can save UDT Arrays to file.

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 14th Aug 2010 08:14 Edited at: 14th Aug 2010 08:29
Yes... Yes I do have the matrix1 plugins, but there is a command in there that does what I need? Excellent thank you muchly

*edit*
the only thing i could find was SAVE ARRAY TO DATAFILE is that the one? i couldn't find any write/read command for arrays

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th Aug 2010 17:16
Yeah, sorry for being so vague, that's the one.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Aug 2010 18:19
Quote: "the only thing i could find was SAVE ARRAY TO DATAFILE is that the one? i couldn't find any write/read command for arrays"


The other file is LOAD ARRAY FROM DATAFILE. Once you use that command the array is filled up with all the data. You just use it like you would any array.

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 14th Aug 2010 21:39 Edited at: 14th Aug 2010 21:43
Ok so i was using the right one.. BUT when i used it in my code i got an error message saying Runtime Error - The Matrix1Util_22.dll plug-in is not available at line 679 now the "help" file says :- "This command will cause the array to be saved into the datafile specified. It will handle arrays of both basic and UDT types.

The array must be correctly DIM'med before use or else an error will be triggered."
but it does not specify what "correctly DIMed" means... as far as i know i have "correctly DIMed" my array *see above* and this is how i used it in my coding
correct yes/no?

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Aug 2010 22:55
Yeah it should work. You may need to reinstall it.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

Quote: "The array must be correctly DIM'med before use or else an error will be triggered." but it does not specify what "correctly DIMed" means... as far as i know i have "correctly DIMed" my array *see above* and this is how i used it in my coding"


The only weird thing about your DIM statement is you don't really need GLOBAL in front of it... arrays are global by default. I'm not sure why it wouldn't work.

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 15th Aug 2010 05:06
well given that i'm not all that good with arrays i don't know entirely how to use them and the examples i was given had global dim at the beginning so i just went with it, but yeah those commands aren't working too great for me right now, and i only re-installed them like... yesterday? maybe the day before

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 15th Aug 2010 21:43 Edited at: 15th Aug 2010 21:52
well i tried removing them and then re-installing them again, but still all to no avail, i can't see that i've done anything wrong at all, everything is DIMmed and everything works except saving

*edit*

I think i have found the problem but i still can't figure out how to get it to work, i'm using Open datafile to write and my program won't compile at all
this is how i have it in my code

correct?

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Aug 2010 02:10 Edited at: 16th Aug 2010 02:11
Yeah it should work that way. I never used IanM's SAVE ARRAY TO DATAFILE command till you posted about it and it works flawlessly. Even if you erase all the elements in the array it resizes the array to fit the load data automatically.

The following works on my computer... try it and tell me the results.



I'm definitely going to use IanM's SAVE/LOAD ARRAY TO/FROM DATAFILE commands for projects that require small UDTs. IanM has done it again.

Login to post a reply

Server time is: 2024-09-28 20:31:42
Your offset time is: 2024-09-28 20:31:42