#1✎ 43ArrowStill trying TO make a save function how to use save"txt with array to create save function so players can save progress
#2✎ 43ArrowI got it to save using save"txt for each variable but that would have me saving a bunch of times every time I want to save so I need an array
#3✎ 272TheV360Pokemon Is Awesome!I love Pokemon!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfAre the things you are saving numbers?
#4✎ 43ArrowI'm creating a rpg the variables I'm trying to save are for the players stats
#5✎ 272TheV360Pokemon Is Awesome!I love Pokemon!Express YourselfFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfPut this code near the beginning:
It will make an array (essentially a bunch of variables put into one) that will store your save data.
When you want to save, use this:
The first 5 lines put your variables into the array, and the final line saves the array as a DAT file.
Arrays start with 0 for some reason... If you have an array with 5 things in it, the array will go from 0-4. Odd.
When you want to load, use this:
If I remember correctly, this will only work with integers. You can't save real numbers as DAT files. (Integers are variables that can't have decimal points and real numbers are the ones that can)
If your numbers ARE real numbers, then you can use this method, but it's a bit more complex. It's like your original method, but it puts multiple numbers into one string.
To save, use these lines of code:
The first line puts all the variables together, separated by *s using the STR$ function, which converts numbers to strings.
Here's where it gets complex. To load, use these lines of code:
LOAD "TXT:SAVEDATA",0 OUT SAVE$
SP=VAL(SAVE$)Oh boy... This is a mess. This chunk of code takes each value out of SAVE$, one by one. As you can see, there are two core copy-and-pasted lines in this: the VAL(...) and the MID$(...). The VAL() line pretty much says "find the first value I see out of the SAVE$ variable and put it into ATK, DEF, etc." The MID$() line takes what it just found out of the SAVE$ variable. The last VAL() line is different because there are no *s left in the SAVE$ variable, so it just takes the last value and puts it into SP.
Edit: how did i not see the mistake
#7✎ 477SquareFingersSyntax error on what line?
Also, LEFT$ and RIGHT$ are your friends.
#8✎ 188412Me21Syntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express Yourselffor saving numbers, I strongly reccommend that you use DAT files
SAVE "DAT:SAVEFILE",SAVEARRAYand then
#9✎ 43ArrowI tried it and it gave me type mismatch. DAT didn't work need to figure out txt I know txt works I just don't how to save multiple variables at once.
Have you tested the DAT code because last time I tried it didn't work here's the key for the rpg I'm working on see if you can get save function to work
Stats = atk
Stats = dfn
Stats = hpv
Stats = hpm
Stats = coin
Stats = lvl
Stats = c
Stats = armor
Stats = eq
#10✎ 477SquareFingersTry putting DAT: at the beginning of the filename (inside "").
#11✎ 1110randomousOwnerRobotHiddenEaster EggsSecond YearMy account is over 2 years oldWebsiteDrawingI like to draw!HobbiesArrow, I would appreciate it if you learned how to use a forum. This isn't like text messaging: in a forum, you usually make a single post as a response and edit it when you need to add stuff.
The only time you should add a new post is if you're replying or if what you're posting has absolutely NOTHING to do with your previous post. I'm fixing your posts; please keep this in mind in the future.
#12✎ 43ArrowI did in the code I forgot that part when I was making the post
Also, here's more code:
#13✎ 477SquareFingersIt makes it very difficult to help you when you 'forget' things like that. If you want help, I suggest you 'remember' to give accurate information. What line gives the type mismatch?
#14✎ 43ArrowSorry about that I messed because I'm half asleep my cousin kept me up late last night
Type mismatch in 1350
#17✎ 477SquareFingersThe variable STATS: is there one or more DIM or VAR lines declaring it? Where are they (specifically, inside or outside DEF blocks)?
#18✎ 43ArrowNot that I can find the key is D4X2E4D can you check it
#19✎ 43ArrowI don't think DAT will work I've gotten TXT to work but not the way I need
#20✎ 477SquareFingersIf the variable STATS is not declared, that's a problem. At or near the beginning of your code (but after CLEAR, if you use it), include
(or 5 or whatever the proper number is).