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 / Load Array error

Author
Message
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 9th Aug 2008 20:35
managed to get the program to create a saved game; at least, it creates the arrays not sure if the players stats are in actually there.

then i started on the code to load the saved game by having the player enter the name of their charactor.



when i type in the name of the charactor i saved and hit enter, nothing happens. hitting enter again results in the "the program has encountered an error and needs to close..." window.

ran the .exe again and selected new game. entered the same name (Chaos) as the saved game was trying to load. same thing happened. entered name, hit the enter key, nothing, hit key again, "you screwed up" window appears again.

bit of irony in that. used name "Chaos", program in chaos...

anyways,

thanks for any ideas has to why this is happening.
Anti

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Aug 2008 21:56
Could you post the DIM where you created the array and possibly the part where you save it? Maybe we'd be able to help a little more with that information at hand seeing as you're getting that oh so helpful "the program has encountered an error and needs to close" error.

Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 9th Aug 2008 22:27
i'l edit this post when i get home from work to do that, running late for work.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th Aug 2008 22:40 Edited at: 9th Aug 2008 22:42
Anti Human,

If I am correct you have to create the array(which you will be loading) the size of the saved array. So, if the saved array was 10 slots then the new array being loaded must also be 10 slots. This was the only way I could get the command to work.

However, I wish this wasn't so because it's a bit inefficient. It means that along with saving an array, you also have to save a text file with the size of that array, so that you can get the size of the saved array from it(or at least, that's how I did it). Or, you can save the size on the very last line of the array file, after having saved the array(actually, putting on the last line might not work, unless you have something like IanM's plugins, which include some very nice file editing commands).
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 9th Aug 2008 22:43
is this right do you have 2 files ????
---------------------------------------------
Load Array PLoad$+"$", Player$(0)
Load Array PLoad$, Player(0)
---------------------------------------------

why dose this loke like this
Load Array PLoad$+"$", Player$(0)
shouldt it be
Load Array PLoad$, Player$(0)


cheers
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th Aug 2008 23:41
Antihuman,

Wait, what is the $ character doing all by itself as an addition to the PLoad$ string? This could be a problem also.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 9th Aug 2008 23:52
Quote: "Wait, what is the $ character doing all by itself as an addition to the PLoad$ string? This could be a problem also. "


He probably saves it like that to show that it contains a string (he could do something else...). When I saw that, I tried making a text file (not from DB) and naming it "$$.txt" and had no problems.

Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th Aug 2008 23:54
Good save. Thanks 60[]s.
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 10th Aug 2008 06:38
Alright, not going to edit the above post like i said.

DIMing the arrays,


Saving the Arrays (was proud of this, got it working in two tries):


first off, i think i set it up correctly for the loading with a "$" at the end of one array, as 60[] said it is to show it as a string array.

okay, saving works sorta; it made arrays in the "Saves/" folder.

not sure about the array storing integers, but the array for strings didn't hold the right info.

that is, it is storing the default values for weapons and armor ("Fists" and "Cloth") dispite having been saved after selecting the equipment during charactor creation (right under the DIMs for Player$ and Player.

i was willing to look past that issue at the time i discovered this in favor of working on loading, i wasn't completely awake last night while i was working on this part, but in hind-sight i should have figured that out first, as now it might be causing some of this issue.

as always, i can't sit around while other people possible see the error of my code (which i know needs alot of cleaning.) so i'l be toying with things tonight and check back here before i go to bed.

thanks for the efforts.
Anti

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Aug 2008 13:48 Edited at: 10th Aug 2008 13:49
have a look in the 'save' folder and see what file names to have.

Also make sure you are loading the files from the save files folder.

Dark Physics makes any hot drink go cold.
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 11th Aug 2008 06:44
saved games are "Chaos$" and "Chaos".

i think i have the code to load them correct, at least as far as loading by those file names. the rest of the load game code, idk. i would test it but windows flings pooh faster then a 6 month old chimp when i try to run the program.

alittle off-topic here, but how bad do i suck at this? it's one thing when DB or the compiled exe tells me i screwed up, but to do such an outstanding job as to get mircoshaft's automatic SNAFU messege?

ok, done with the pity trip. anyways. IF you were to write a batch of code to save and load player stats for a would-be RPG, how would you go about?

just fishing here, looking for idea's on how to do this from a different direction.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Aug 2008 12:40
Unless you have a bit more code you have not posted then the above will only look for a file called Pload$, which has the name player in it.

As I do not know how all your code is layed out, I can not say which bit is call first or next.

so the bit that gives all the varables a value is this called before or after load game.

I would say start again now you know how each bit works and write down the flow of how its going to go. each bit may not need to be rewitten just put in the right place.

Dark Physics makes any hot drink go cold.
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 11th Aug 2008 23:26
so its looking for a file with the name of the variable, and not the string in the variable? if so how would i set it up to look for the string?

and the is alot of code i haven't posted but i think i'v posted all relivent pieces...though if you went looking through all my posts you could probably find the rest of it.

the code sloppy, to say the least. but now that i'm thinking about it; i remember seeing my "Charactor not found." line at one point in time. oh crap.

i think HowDo is correct. time to start over.

thanks for all the help though guys, sorry it's doing me little good but it's not any one elses fualt i can make heads or tails of my own code.

*Coding Skill: -1*

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 12th Aug 2008 08:06
*Coding Skill: +1*



it's weird, but it works. woot?

thanks again ya'll

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 12th Aug 2008 12:24
Well Done looks a lot better, I can read it and see where it goes and what it does, keeps this up and you soon move in to the other system of 3D .

you may find learning how to use the case system will be a good one as it can turn this.


into this



up to you, I use to leave it alone until one day I learnt how it worked now I use more when the if's get to more that 5.

anyway happy coding.

Dark Physics makes any hot drink go cold.
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 12th Aug 2008 23:08
i'v never seen that before. looks like it would help, add all the races back in or when i get back to doing the weapons and armor.

on a flip note: i'v got the above code modified so that it saves a array call player$(0), kicks on a .exe, and ends. the .exe then loads player$(0). should help in keeping the actually game smaller and more organized with all the player creation in the first exe.

I'm reading over the command help for select, case, endcase, and endselect. but could anyone explain it in better detail? (in the hopes that i don't have to post a question about it later when i screw up so bad my system reboots while running my source)

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Aug 2008 15:06
Quote: "

"


@HowDo: Shouldn't that be:


because the selected variable is a string?


Anyway, let me try to explain SELECT/CASE. It's quite similar to IF/ENDIF (the CASE statements are at least)

Basically, the SELECT command chooses a variable (it can also choose one slot of an array) that the CASE statements will look at. So, you first have to choose the variable you want to look at. Next, you can start writing your case statements. Now, I like to think of case statements like this: "If it's the case that (insert condition here)...". It's quite similar to an if statement, just without multiple conditions.
So, the "Case 1" in this:


is just like saying "If it's the case that Hello is equal to 1".

Anyway, after we define what the "case" has to be, we write our code just like it was between an IF/ENDIF. Then, when we're done with that case we simply write "ENDCASE" (just like ENDIF) and move on to the next. When we're done with everything, we write ENDSELECT.

One more thing. Say you want the case to perform a default behavior if none of the conditions out of all of the ones you've written in your CASE statements are met. To do that, all you have to do is write CASE DEFAULT after all of your cases are done but before the ENDSELECT. Then, you write the code you want to happen and put ENDCASE after it. It's that simple. Have a look at this example if you still don't understand. Remember that the INKEY$() command returns the key on the keyboard you're pressing as a string. I've stored it in a variable, and will then use a SELECT/CASE statement on it:



Anyway, I hope this helps

Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 15th Aug 2008 03:03
I will (probably) try that some time, when i do ya'll will know because I will (more then likely) screw it up dispite the fact you just laid it out in near simple english (*sniff* do i smell another 60[] tut?)

anyways, the whole reason i'm writing this is to show how i beat my overuse of 'if/endif' statements.



yep, finally got for/next loops working too thanks for all your help guys.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 15th Aug 2008 11:20
That the way to go, write it out the long way, make it work then go back and make it smaller, find bits that repeat themselves and pack them together.

Also keep your eyes open in the forums for the tricks that are given away, that you may be doing in 10 lines and they show how to do in three.

cheers.

Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-09-27 18:23:39
Your offset time is: 2024-09-27 18:23:39