Sinisterly
variable holders for games - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: variable holders for games (/Thread-variable-holders-for-games)



variable holders for games - Inori - 08-22-2014

A while ago I was making a batch RPG and realized you can save files with the ">" function that can have any ".whatever" extension. This got me thinking.
In a week's time, I'd come up with the system. This is how it went down.

Example:
The Problem:
You want to save a character name.
The Code:
Code:
@echo off echo enter character name set /p name= ;redundancy, just for good measure goto :a :a cls %name% > C:\[filepath]\charstat.name echo name: %name% pause <nul
what this will do is send the "name" variable, in .txt format, to a newly created file called "charstat.name" (character stat, name) in the specified filepath.
each time the code is executed, it will overwrite the file and use the new name.

New Problem:
how do I use this?
The Code (I think?):
Code:
@echo off set /p name= %name% < C:\[filepath]\charstat.name echo %name% pause <nul
What this does (again, I think) is get the name file and set it to the "name" variable.

This can also be used for any alpha-numeric variable you need stored in your game, from mob HP to Drop Rates.
If there's anything you think could be improved or anything wrong with the code (the second bit especially) feel free to PM me!

Enjoy!
-[blank]

Sidenote: sadly, I never released batventures. It was being produced near the end of the school year and even I have priorities :Not-Amused:


variable holders for games - Inori - 08-22-2014

A while ago I was making a batch RPG and realized you can save files with the ">" function that can have any ".whatever" extension. This got me thinking.
In a week's time, I'd come up with the system. This is how it went down.

Example:
The Problem:
You want to save a character name.
The Code:
Code:
@echo off echo enter character name set /p name= ;redundancy, just for good measure goto :a :a cls %name% > C:\[filepath]\charstat.name echo name: %name% pause <nul
what this will do is send the "name" variable, in .txt format, to a newly created file called "charstat.name" (character stat, name) in the specified filepath.
each time the code is executed, it will overwrite the file and use the new name.

New Problem:
how do I use this?
The Code (I think?):
Code:
@echo off set /p name= %name% < C:\[filepath]\charstat.name echo %name% pause <nul
What this does (again, I think) is get the name file and set it to the "name" variable.

This can also be used for any alpha-numeric variable you need stored in your game, from mob HP to Drop Rates.
If there's anything you think could be improved or anything wrong with the code (the second bit especially) feel free to PM me!

Enjoy!
-[blank]

Sidenote: sadly, I never released batventures. It was being produced near the end of the school year and even I have priorities :Not-Amused:


variable holders for games - Inori - 08-22-2014

A while ago I was making a batch RPG and realized you can save files with the ">" function that can have any ".whatever" extension. This got me thinking.
In a week's time, I'd come up with the system. This is how it went down.

Example:
The Problem:
You want to save a character name.
The Code:
Code:
@echo off echo enter character name set /p name= ;redundancy, just for good measure goto :a :a cls %name% > C:\[filepath]\charstat.name echo name: %name% pause <nul
what this will do is send the "name" variable, in .txt format, to a newly created file called "charstat.name" (character stat, name) in the specified filepath.
each time the code is executed, it will overwrite the file and use the new name.

New Problem:
how do I use this?
The Code (I think?):
Code:
@echo off set /p name= %name% < C:\[filepath]\charstat.name echo %name% pause <nul
What this does (again, I think) is get the name file and set it to the "name" variable.

This can also be used for any alpha-numeric variable you need stored in your game, from mob HP to Drop Rates.
If there's anything you think could be improved or anything wrong with the code (the second bit especially) feel free to PM me!

Enjoy!
-[blank]

Sidenote: sadly, I never released batventures. It was being produced near the end of the school year and even I have priorities :Not-Amused:


RE: variable holders for games - RaccoonCity_mybb_import13707 - 08-25-2014

With the help of the saved file, it'll always remember the name.

Pretty smart! Smile