1

Well, I'm trying to make a basic RPG in batch (Don't judge me) and I'm in a bit of a predicament with equiping items. It's a bit hard to explain so here's some code:

set inv1=sword
...
set inv9=empty
echo which item do you want to equip?
echo.
echo 1) %inv1%
...
echo 9) %inv9%
echo.
set /p c="> "
set invt=inv%c%
set type=%invt%_type
if "%%type%%"=="equipable" (
set itemslot=%invt%

basically, I need to replace %%type%% with the value of the value of 'type'. Is there any way to do this? if so, it would save me many lines of code and make it FAR easier to implement new items. THANKYOU to anybody who can help. (and, yes, I have searched the internet, this forum and other forums but no help :( )

stenstorp
  • 31
  • 2
  • I don't judge you. But for your sake I hope you consider using other languages like Ruby instead. Not only would it be easier for you but it would save porting your application to other platforms as well. – konsolebox Aug 03 '14 at 09:59
  • Use an intermediate variable (VALUE) like in `call set VALUE=%%type%%`. See http://stackoverflow.com/questions/10231334/how-can-i-pass-a-variable-name-as-part-of-a-parameter-to-a-batch-file-and-then-u?rq=1 – halfbit Aug 03 '14 at 09:59

1 Answers1

0

Is this going to work in your case?

call set "t=%%type%%"
if /i "%t%"=="equipable" (
set itemslot=%invt%

edit This is the same as the comment by halfbit

foxidrive
  • 40,353
  • 10
  • 53
  • 68