Saved Bookmarks
| 1. |
Solve : How do I make a save file?? |
|
Answer» OMG first post For my game, I want to make a save file. I already have this code: Code: [Select]( echo %Name% echo %HP% echo %LV% ) > %Name%Save.lsavto save. How do I make the batch file read each line? Please HELP!The > redirection operator has an opposite operator the < to pass from file back to the VARIABLE. http://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file Quote Read file contents into a variable: also more here on this: http://www.robvanderwoude.com/redirection.php Okay, let me rephrase. How do I make it read every line? I want this: Save File: 1234 4321 1324 Now in the batch file: (Sets the variables to the line) %Line1% = 1234 %Line2% = 4321 %LINE3% = 1324 Quote from: Luigi master on June 11, 2016, 12:55:36 PM Okay, let me rephrase. There are many ways to skin this cat: using this format when creating the save file allows you to rename the .lsav file and add a .bat extension, which you call and rename the file back again. All your variables are set. Code: [Select]( echo set name=%Name% echo set HP=%HP% echo set LV=%LV% ) > %Name%Save.lsavI'm not sure this topic was resolved, or if the OP FOUND it helpful. To reiterate what Foxidrive said with an example: :save ( echo %health% echo %bees% )>textfile.txt :load ( set /p health= set /p bees= ) Use "Echo" to set the variable, "set /p" to load it. Also NOTE the direction of the carrots. ">" to save, "<" to load. Hope that helps! |
|