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.

DarkBASIC Professional Discussion / UDT, Array and file save question?

Author
Message
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 17th May 2013 02:02 Edited at: 17th May 2013 02:22
I have not had a chance to play around with this but will this weekend. I do have working code. Here is some psudo code for my question. This is slimmed down from my code as my UDT has about 20 vars.



Maybe I need to think on this a little more but thought I would check here. I have code similar to this that works, rolls for stats, prints six stats on the screen all at once after enter is hit also a re-roll option. My question is

in the code you can see I have defined the values for player 1. my character array is for 25 characters so this should store this info in element 1 of the array. So if they do a save on the character and then come back later and decide to create another character how will the program know to store the next character in position 2 of the array and so on down the line until the character array is full? Do I have to hard code for each character? I don't think so but not sure how to do it.

Also I have seen from reading code most of the time file save and load code right there with code like this. Does it have to be that way or can I put it in a function so my character load and save code can be called from different places in the overall program?

Thanks
Dragonslayer

I am at my PC now so I will post my code. I am sure there are better and more efficient ways to do it but this works and I learned to do it with minimal posts here to figure it out. Feel free to take it if you want and feel free to comment on it. Maybe I will learn more!!!

Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 17th May 2013 05:17
Quote: "in the code you can see I have defined the values for player 1. my character array is for 25 characters so this should store this info in element 1 of the array. So if they do a save on the character and then come back later and decide to create another character how will the program know to store the next character in position 2 of the array and so on down the line until the character array is full? Do I have to hard code for each character? I don't think so but not sure how to do it."


well, you load in to the same index you save out, so if char A takes index 1 whn you save, itll still be on index 1 when you load. when char B is made, you can either run through the array to find an empty spot, or make it a variable length list and jut use "array insert at bottom plrChar()" to create a new index

Shazam!
Dragon slayer
19
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 18th May 2013 03:01
I figured so, I will have to play around with it.

Login to post a reply

Server time is: 2026-07-06 18:37:40
Your offset time is: 2026-07-06 18:37:40