locked
Save Option RRS feed

  • Question

  • CDP104 <-- full game code

    I pretty much made most of the game. Took me 3 days including today. :D

    I don't how to make it so the player can save their game?  Is it even possible?????




    • Edited by Dinomite07 Wednesday, September 10, 2014 4:38 AM
    Sunday, September 7, 2014 1:17 AM

Answers

  • How about CDP104-1 ?

     


    Line 20  init_variables()    '  sub name changed // array variables and sub variables are same name
    Line 24-44  added subroutine init_variables
    Line 46-88  added subroutine Set_Variables_data
    Line 117 Set_Variables_data()   ' set   initial data to varibales array

    Line 122 variables= File.ReadContents(path)  ' load  saved data(varibales array)
    Line 123 Set_Variables_data()  ' set variables array to initial  data(Updated)
    Line 283 lol=1
    Line 284 Set_Variables_data()  '  set  updated data to varibles array
    Line 286  File.WriteContents(path, variables)  '  save  variables array data
    Line 475  init_variables() 


    • Edited by NaochanONEditor Wednesday, September 10, 2014 8:20 AM
    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:24 PM
    • Marked as answer by Dinomite07 Wednesday, September 10, 2014 10:35 PM
    Wednesday, September 10, 2014 8:18 AM
    Answerer

All replies

  • I think it's possible. Save variables into a file. And make Load menu to load variables from the file.

    Nonki Takahashi

    • Proposed as answer by litdev Sunday, September 7, 2014 2:28 PM
    Sunday, September 7, 2014 1:53 AM
  • im not sure how to do it on small basic

    you save the game

    exit

    come back on

    load it

    and you are at where you left off.


    • Edited by Dinomite07 Sunday, September 7, 2014 5:28 AM
    Sunday, September 7, 2014 2:09 AM
  • Is there a command to save it to a file?
    Monday, September 8, 2014 1:55 AM
  • Is there a command to save it to a file?

    This is a sample.

    path = File.GetSettingsFilePath()
    variables["hp"] = hp
    variables["stage"] = stage
    File.WriteContents(path, variables)
    


    Nonki Takahashi

    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:23 PM
    Monday, September 8, 2014 2:08 AM
  • where would the variables export to?

    Sub variables
    PLAYERHP = 100 'Intial value of player's HP 
    gold = 0 
    exp = 0
    xxx = 0
    yyy = 0
    HPPot = 3
    SmokeBomb = 3
    EndSub

    btw they all change when you are playing the game so i want changed variables to be saved and when you load the game it loads one the changed variables
    • Edited by Dinomite07 Monday, September 8, 2014 2:38 AM
    Monday, September 8, 2014 2:31 AM
  • where would the variables export to?

    Sub variables
    PLAYERHP = 100 'Intial value of player's HP 
    gold = 0 
    exp = 0
    xxx = 0
    yyy = 0
    HPPot = 3
    SmokeBomb = 3
    EndSub

    btw they all change when you are playing the game so i want changed variables to be saved and when you load the game it loads one the changed variables
    Yes, I think you need all these variables to save.  If the player selects "Start New Game" then call this subroutine.  If the player selects "Load Last Game" then these variables should be initialized with values from a file.

    Nonki Takahashi

    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:23 PM
    Monday, September 8, 2014 3:23 AM
  • CDP104 <-- full game code

    ElseIf lol = 2 then (this is where the game loads the variables)

      If loc = 5 Then
        (this is where the game stores the variables)
    Where would the variables be exported to?




    • Edited by Dinomite07 Wednesday, September 10, 2014 4:37 AM
    Monday, September 8, 2014 3:30 AM
  • Help, where does the variables get exported to and how would I extract them?

    path = File.GetSettingsFilePath()

    variables["hp"] = PLAYERHP
    variables["gold"] = gold
    variables["exp"] = exp
    variables["xxx"] = xxx
    variables["yyy"] = yyy
    variables["HPPot"] = HPPot
    variables["SmokeBomb"] = SmokeBomb
    File.WriteContents(path, variables)

    i dont understand these commands

    path = File.GetSettingsFilePath()

    File.WriteContents(path, variables)

    • Edited by Dinomite07 Tuesday, September 9, 2014 3:25 AM
    Tuesday, September 9, 2014 1:27 AM
  • Help, where does the variables get exported to and how would I extract them?

    path = File.GetSettingsFilePath()

    variables["hp"] = PLAYERHP
    variables["gold"] = gold
    variables["exp"] = exp
    variables["xxx"] = xxx
    variables["yyy"] = yyy
    variables["HPPot"] = HPPot
    variables["SmokeBomb"] = SmokeBomb
    File.WriteContents(path, variables)

    i dont understand these commands

    path = File.GetSettingsFilePath()

    File.WriteContents(path, variables)

    To understand how your code works, I recommend you to see variables with TextWindow.WriteLine(var) or TextWindow.Title = var.
    See the contents for variables variables and path.  A variable variables is an array.  And a variable path contains a text file name.  You can open the file with Notepad or other text editor or just see type command in command prompt.

    Nonki Takahashi


    • Edited by Nonki Takahashi Tuesday, September 9, 2014 5:34 AM Graphics to Text
    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:24 PM
    Tuesday, September 9, 2014 5:33 AM
  • Try this.

    path=program.Directory+"\var_data.txt"
    PLAYERHP = 100 'Intial value of player's HP
    gold = 0
    exp = 0
    xxx = 0
    yyy = 0
    HPPot = 3
    SmokeBomb = 3
    variables["hp"] = PLAYERHP
    variables["gold"] = gold
    variables["exp"] = exp
    variables["xxx"] = xxx
    variables["yyy"] = yyy
    variables["HPPot"] = HPPot
    variables["SmokeBomb"] = SmokeBomb
    '
    TextWindow.WriteLine(variables)
    File.WriteContents(path, variables)   '<------------

    Newvariables=File.ReadContents(path)    '<------------
    TextWindow.WriteLine(newvariables)

    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:24 PM
    Tuesday, September 9, 2014 6:28 AM
    Answerer
  • CDP104 <-- full game code

    ElseIf lol = 2 then
      TextWindow.Clear()  
      Newvariables=File.ReadContents(path)   
      selectLocation()

    (How would the new variables replace the starting ones below?)

    Sub variables
    gold = 0
    exp = 0
    xxx = 0
    yyy = 0
    HPPot = 3
    MPPot = 3
    SmokeBomb = 3
    level = 0
    str = 10
    end = 10
    int = 10
    intinc = 0
    vit = 10
    vitinc = 0
    sp = 0
    PLAYERHP = 100 + vitinc
    PLAYERTOTALHP = 100 + vitinc
    PLAYERMP = 30 + intinc
    PLAYERTOTALMP = 30 + intinc
    EndSub


    • Edited by Dinomite07 Wednesday, September 10, 2014 4:39 AM
    Tuesday, September 9, 2014 11:29 PM
  • How about CDP104-1 ?

     


    Line 20  init_variables()    '  sub name changed // array variables and sub variables are same name
    Line 24-44  added subroutine init_variables
    Line 46-88  added subroutine Set_Variables_data
    Line 117 Set_Variables_data()   ' set   initial data to varibales array

    Line 122 variables= File.ReadContents(path)  ' load  saved data(varibales array)
    Line 123 Set_Variables_data()  ' set variables array to initial  data(Updated)
    Line 283 lol=1
    Line 284 Set_Variables_data()  '  set  updated data to varibles array
    Line 286  File.WriteContents(path, variables)  '  save  variables array data
    Line 475  init_variables() 


    • Edited by NaochanONEditor Wednesday, September 10, 2014 8:20 AM
    • Proposed as answer by Ezra94 Wednesday, September 10, 2014 3:24 PM
    • Marked as answer by Dinomite07 Wednesday, September 10, 2014 10:35 PM
    Wednesday, September 10, 2014 8:18 AM
    Answerer