? How do I save and load data? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

How do I save and load data?

  • #1 ✎ 37 OChunksHD Night Person I like the quiet night and sleep late. Express Yourself Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I have a map that randomly generates trees via numerical array, but I need to know how to keep the map from regenerating trees if e.g. you go to a town and come back to the map... I think saving and loading the array can do the trick, but I don't know how to do so. Please help. Posted
  • #2 ✎ 37 OChunksHD Night Person I like the quiet night and sleep late. Express Yourself Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength It looks like this... dim map[8,8] 'real map is bigger, this is just an example For y=0 to 7 For x=0 to 7 Read c map[x,y]=c If c==3 and rnd(9)==0 then c=1 elseif c==3 and rnd(90)==0 then c=2 elseif c==3 then c=0 if c==0 then 'make the grass stuff's if c==1 then 'make the trees''this code isn't necessary for me to state, so I'm not including it in my example' if c==2 then 'make water' next next Data 1,1,1,1,1,1,1,1 Data 1,3,3,3,2,2,3,1 Data 1,3,3,2,2,3,1,1 Data 1,3,3,2,2,3,3,1 Data 1,3,3,3,3,3,3,1 Data 1,3,0,0,0,2,3,1 Data 1,1,3,3,3,3,3,1 Data 1,1,1,1,1,1,1,1 Posted
  • #3 ✎ 1510 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website You can save an array with: SAVE "DAT:filename",ARRAY And load arrays using: LOAD "DAT:filename",ARRAY,0 (the 0 disables the dialog box that normally appears when loading files (but this can't be done while saving)) Posted
  • #4 ✎ 37 OChunksHD Night Person I like the quiet night and sleep late. Express Yourself Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I tried that. What line of code should I have to load command? Posted
  • #5 ✎ 230 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I'm not sure what that is? If you want to make a "load save" option in a game it's as simple as doing menu stuff and calling LOAD based on the menu option. Posted