| 1. |
Solve : Save/load help? |
|
Answer» Ok I need some help with a test file to load data from a save state after checking if it even exist. if exist "tsgb%name%.txt" goto loader instead of if exist ("tsgb%name%.txt") goto loader Ok that sort of worked. Now I get a whole new issue. The output on the :loader screen now reads Environment variable tsgbjasperjester.txt not defined. Done. Please check stats to verify. just as a note i tried removing the () around the Code: [Select]for /f %%a in ("tsgb%name%.txt") do set %%a but it just closed immediately. thank you again for the helpCode: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a If that text file just has one line of text in it and you are trying to assign it to a variable then just do this. Code: [Select]set /p myvar=<tsgb%name%.txtQuote from: Squashman on July 12, 2013, 08:15:29 PM Code: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a Uh, I'm not sure what that was supposed to do but it did no load the changed variables at all. I am actually trying to change 5 in this test game, but there 12 variables in the full game.Quote from: Jasperjester on July 12, 2013, 08:10:43 PM The output on the :loader screen now reads Yes, that is a different command and has different syntax and it should be: Code: [Select]for /f "delims=" %%a in ('type "tsgb%name%.txt" ') do set variable=%%a but this will only populate the variable to the last line in the file Quote from: foxidrive on July 13, 2013, 04:07:03 AM but this will only populate the variable to the last line in the file ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded, this will require me to enter the same line at least 8 times for each player totaling 36 times and creating 36 small files for each player stats alone not including the money and inventory systems I have in place. I need all this in a maximum of 6 pages. There are already 4 people here who are testers and react differently and that would seriously bloat the folder in which the files are saved.1. Writevals.bat @echo off REM save values set name=Joe set money=1000 set energy=50 set friend1=Mary set friend2=Jim set friend3=Peter if exist "%name%.values" del "%name%.values" echo money=%money% >> "%name%.values" echo energy=%energy% >> "%name%.values" echo friend1=%friend1% >> "%name%.values" echo friend2=%friend2% >> "%name%.values" echo friend3=%friend3% >> "%name%.values" 2. Joe.values money=1000 energy=50 friend1=Mary friend2=Jim friend3=Peter 3. Readvals.bat @echo off REM read values set name=Joe set money= set energy= set friend1= set friend2= set friend3= for /f "delims=" %%A in ('type "%name%.values"') do ( set %%A ) echo name=%name% echo energy=%energy% echo friend1=%friend1% echo friend2=%friend2% echo friend3=%friend3% 4. Output of Readvals.bat name=Joe money=1000 energy=50 friend1=Mary friend2=Jim friend3=PeterQuote from: Jasperjester on July 14, 2013, 01:18:43 AM ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded I was pointing out that your syntax was wrong and it would not read a file at all.Quote from: foxidrive on July 14, 2013, 05:05:37 AM I was pointing out that your syntax was wrong and it would not read a file at all. Oh, I apologize for the misunderstanding. I hope you may forgive my ignorance on the matter. I am still learning Quote from: Salmon Trout on July 14, 2013, 02:49:42 AM for /f "delims=" %%A in ('type "%name%.values"') do ( Had an issue where it wouldn't read the files at first, but it turned out, I forgot the tsbg before the %name%.values Kudos for all the help!!!!!!!!!!!!!What is a 'tsbg'? Quote from: Salmon Trout on July 14, 2013, 07:05:51 AM What is a 'tsbg'? tsbg was a prefix I added to make sure i never mixed up the test save batch game with the real game save files. example: Code: [Select]tsbg%name%.values vs Code: [Select]realgame%name%.values |
|