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 / Can't read a saved array.

Author
Message
gameangel147
11
Years of Service
User Offline
Joined: 2nd Dec 2012
Location:
Posted: 1st Feb 2014 05:00
So I have had trouble reading saved arrays from a DAT file. I currently have it set up so that each level array is stored in a DBA file, but if I am going to have lots of levels, it's going to take up lots of lines of code, so I was planning of saving arrays to file and loading them when needed.

My current code is:



It reads the label and reads the data into the array and then places the given tile.

The new way I tried doing it was rather than calling the label, I would open the rile and load the array.



And this is the program I used to save the array into a file, which was done in a separate program.



For some reason the values of the array won't be read. Any help would be greatly appreciated.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Feb 2014 19:34
I quickly looked through this without actually running it, but something I would check first are the filenames.

You save it as
Quote: "save array "lv_1.dat", lv_1(25, 17)"


but yet you reload it as
Quote: "open to read 1, "lv_1_map.dat""


Not 100% sure if that is it, but your filenames have to match.

So many games to code.....so little time.
gameangel147
11
Years of Service
User Offline
Joined: 2nd Dec 2012
Location:
Posted: 2nd Feb 2014 06:14
Yeah, that's a typo, my code has the file listed correctly. I test it by listing an image number and it works, but when I use the array as the image number then it says the number is invalid, and I'm not sure I know how the load array command works. I thought it loads the array from the file, but maybe it loads the data into another array?

Also to run the code, there needs to be a REPEAT/UNTIL loop after teh sprites are made to keep the program running. That function is only one part of the program, but it doesn't depend on anything else except for needing to create the lv_1 array.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 2nd Feb 2014 19:15 Edited at: 2nd Feb 2014 19:16
Okay, I'm not following the way you are using the TYPE variable for the sprites. As I see it, this code:



Should look something like this:

I made up some images, ran the code to save the file and ran it with this function and it worked. Hope this is helpful.

Also, it is worth noting that you do not need the array data listed in this function (as you had it), as you have already saved it to your hard drive and are loading in the array.

So many games to code.....so little time.
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 2nd Feb 2014 19:53
Don't know whether it helps or not but IanM's matrix plugins allow you to save out and load in udts with arrays...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...

Login to post a reply

Server time is: 2024-04-19 11:07:28
Your offset time is: 2024-04-19 11:07:28