Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

I need help with a game I'm making in Batch.?

Ok so I am making a game in batch and I'm having trouble with 4 different features. The first is with the spending money for equipment and other similar items in game. I need a line of code that will cause the user to be prompted with the message, "You do not have enough money" and the money will not be spent. The next two features that I am having trouble with is the saving and loading feature. I need to save all of the stats such as strength, defense, intelligence, luck, name, sex, current location, ect. in a seperate file that will remain after command prompt is closed. From there I need to be able to open the game in command prompt, click load, select the file (i.e. slot1, slot2, slot3), and have it load the stats and take me to the current location (reminder: current location is already set as a variable that was saved. Also I need to be able to delete a save file from the load or save menu.

Please do not just past a line of code and tell me it will work. Explain the how each piece of the line of code works or I won't use it. Tutorials are fine to post as long as they follow the previously stated rule.

Thank you in advance to anyone who provides help in this delima.

1 Answer

Relevance
  • Aacini
    Lv 4
    1 decade ago
    Favorite Answer

    I may help you with the saving and loading stats parts.

    I suppose you keep the stats in several variables with appropiate names. You may use this method to store in a disk file the current values of the variables:

    echo set strength=%strength%> slot1.bat

    echo set defense=%defense%>> slot1.bat

    echo set intelligence=%intelligence%>> slot1.bat

    echo set luck=%luck%>> slot1.bat

    echo set name=%name%>> slot1.bat

    echo set sex=%sex%>> slot1.bat

    echo set current location=%current location%>> slot1.bat

    Previous lines will create slot1.bat file that contains several set commands with the variables and its current values. This way, to recover such values you just need to execute that file:

    call slot1

    If all variables are inter-related, when you load a whole set of values your game should recover that location.

    I hope it helps.

    Regards...

    PS - I suggest you to break down your problem into several simpler questions. Perhaps you may show a part of your program and request for a small missing piece you need...

Still have questions? Get your answers by asking now.