Solved I need help with this batch file game

September 19, 2012 at 08:42:19
Specs: N/A
http://imgur.com//11O1L

When I run the batch file it gets to this but when I type the word it says missing operator in a very brief flash. If you know what te missing operator is I would appreciate it.


See More: I need help with this batch file game

Report •


✔ Best Answer
September 19, 2012 at 18:12:27
Lol!, yeah, the (f/e) was not code, it meant: "for example". And the code I posted eliminated the "constant" issue, so you should be ok with it, other than initializing all players bank accounts (another assumption) to 5000 dollars:
set $=5000

at the beginning of your game.

ps: just for fun, here's my approach:
set $=5000
set pistol=30
set frog=5
::{etc for all items}
::...
:: clear the variable before all set /p!
set buy=
set /p buy=
:: user enters Pistol, then value "30" replaces "%buy%" in the adjustment:
set /a $ - = %buy%
echo new balance: %$%
:: ======= end
(variable names are not case-sensitive: pistol=Pistol=PISTOL)



#1
September 19, 2012 at 09:39:12
what word are you typing? my guess is that it is having trouble with this line

if %buy%==bulletproof-vest setlocal/a 5000=%$%-20

then again, I am not so sure that I would use $ as a variable, I was thinking that normally this would have to be escaped.

:: mike


Report •

#2
September 19, 2012 at 09:46:05
It isn't just the bulletproof-vest...I can easily fix that. It says missing operator on everything.

Report •

#3
September 19, 2012 at 11:03:17
have you tried using fivethousand (this worked on mine) instead of 5000, for some reason, mine doesn't like the 5000.

:: mike


Report •

Related Solutions

#4
September 19, 2012 at 17:14:01
I agree with Mike, a variable named "5000" will totally confuse "set /a" operation, because it sees that as numeric constant, and you can't assign a value to a constant. also, the setlocal /a looks like a mistake. it should be like the others: set /a
Also, just guessing and probably wrong, but if you intend to decrease a players bank account (%$%) by the value of the purchase, then you would want like this (f/e):
if %buy% equ pistol set /a $ - = 30

Report •

#5
September 19, 2012 at 17:31:15
So just to be sure it would be something like this for all of them?

If %buy% equ helmet set /a $ -=10
And what do I do about it being interpreted as a constant?

And I'm starting to sound like a joke but what about the (f/e) where would I put it and what do I do with it?


Report •

#6
September 19, 2012 at 18:12:27
✔ Best Answer
Lol!, yeah, the (f/e) was not code, it meant: "for example". And the code I posted eliminated the "constant" issue, so you should be ok with it, other than initializing all players bank accounts (another assumption) to 5000 dollars:
set $=5000

at the beginning of your game.

ps: just for fun, here's my approach:
set $=5000
set pistol=30
set frog=5
::{etc for all items}
::...
:: clear the variable before all set /p!
set buy=
set /p buy=
:: user enters Pistol, then value "30" replaces "%buy%" in the adjustment:
set /a $ - = %buy%
echo new balance: %$%
:: ======= end
(variable names are not case-sensitive: pistol=Pistol=PISTOL)


Report •

#7
September 19, 2012 at 18:54:44
Ok so it works now but it keeps reverting back to 5000 when you enter another item...do you do a different tag for each purchase to fix this?

Report •

#8
September 20, 2012 at 08:03:42
Ok I made a few tweaks to that and it worked wonders. Thanks a lot for explaining it in more detail than mike

Report •


Ask Question