Batch File RPG Questions

September 27, 2012 at 07:33:50
Specs: Windows XP
I am trying to make a batch rpg, but I don't know how to set up a constant money system for you to see and to buy things, and the money adapts to how much you spent. I also don't know how to set up if you bought and item, and it says it is there without having to type echo every time you see your inventory and such. Also how can I set it to show your character's name after you make it? Like to create a character's folder with multiple text files with the user's names, and the passwords in the text file. Then for like a log in system?

See More: Batch File RPG Questions

Report •

#1
September 27, 2012 at 14:14:06
I would suggest utilizing a text file for money, and for items.

so perhaps ask the charactors name and create a folder
set /p user="please enter your charactors name: "
mkdir c:\rpg\%user%

as the charactor picks up items you could add them into
c:\rpg\%user%\items.txt

this might enable you to store and recall.

depending on the set up for the user

you could change the title of the window to
TITLE %user% within RpG(or whatever)
or an echo with the main status screen? depending on how you have it set up.

I recommend reading up on (href="http://ss64.com/nt/syntax.html)redirection, for /f, echo. these are things that can be helpful when setting this up.

:: mike


Report •

#2
September 27, 2012 at 20:01:01
for your variable for money this will work. I set it so that you start with 100 dollars. you can change that.
set money=100
ECHO ^$^%money%

every time the player makes a purchase youll add/ subtract some value from the variable money. for example if the player buys a taco:
set /p userinput= Press 1 to purchase a taco for 10 dollars:
IF userinput==1 set %money%=%money%-10
ECHO ^$^%money%

Ill program a whole little taco bell for you as an example
ECHO Press 1 to buy a Taco ($20)
ECHO Press 2 to buy a Burrito ($79)
ECHO Press 3 to buy a Chimichanga ($2)
ECHO Press 4 to buy a Turd ($120)
set /p itemtobuy= Press 1, 2, 3, or 4
IF /I itemtobuy==1 & %money%>0 set %money%=%money%-20 & echo taco>inventory.txt ELSE echo you dont got enough money
IF /I itemtobuy==2 & %money%>0 set %money%=%money%-79 & echo burrito>inventory.txt ELSE echo you dont got enough money
IF /I itemtobuy==3 & %money%>0 set %money%=%money%-2 & echo chimichanga>inventory.txt ELSE echo you dont got enough money
IF /I itemtobuy==4 & %money%>0 set %money%=%money%-120 & echo turd>inventory.txt ELSE echo you dont got enough money


Report •

#3
September 27, 2012 at 21:49:10
Taco Bell (Fire sauces please)

@echo off & setlocal
set money=3000
:1
ECHO Press 1 to buy a Taco ($20)
ECHO Press 2 to buy a Burrito ($79)
ECHO Press 3 to buy a Chimichanga ($2)
ECHO Press 4 to buy a Turd ($120)
set /p itemtobuy= Press 1, 2, 3, or 4
echo index:%itemtobuy%
call :buy%itemtobuy%
:buy1
set deb=20
set bot=Taco
goto :settle
:buy2
set deb=79
set bot=Burrito
goto :settle
:buy3
set deb=2
set bot=Chimi
goto :settle
:buy4
set bot=Turd
set deb=120
goto :settle

:settle
echo settle... %bot%
set test=%money%
set /a test-=deb
if %test% gtr 0 (
set money=%test%
echo bought %bot% new balance: %test%
echo %1>>x_invt.txt
) else (
echo no go: balance rem: %money%, cost of item: %deb%
)
pause
if %money% lss 1 goto :eof
goto :1
::===== end


Report •

Related Solutions

#4
September 28, 2012 at 17:09:05
yeah mine was wrong that looks better. but bot and deb are weird variable names. should name them something clearer but it really dont matter

Report •

Ask Question