• Welcome to the new forums! Server IP: smp.hometownmc.com
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with a game I'm making
#4
Batch may have somewhat simple commands, but it can sometimes be far off from plain English. That, and it's also very limited, which I'm about to show you.

The reason why it doesn't work is because an if statement counts as a single command, and variables are expanded only when they're parsed. This is a common thing people run into once they start using for loops in batch, since this applies to any block of code. To get around this, you have to put "setlocal enabledelayedexpansion" at the top of your script and "! enemyHP!HP" instead of "%enemyHP%HP". The ! denotes a delayed expansion variable.

I guess to put it in simpler terms, you can't set a variable and then read it in the same command, so either set the variable outside of the if statement, or enable delayed expansion and use !'s for any variables set inside the same code block rather than %'s.

Or option 3: learn python lol
[Image: tumblr_nfz4m14xkj1toipevo1_400.gif]
 
Reply
  


Messages In This Thread
I need help with a game I'm making - by firegene - 03-29-2017, 02:06 AM
RE: I need help with a game I'm making - by Saiyaka - 03-29-2017, 04:33 AM

Forum Jump:


Browsing: 7 Guest(s)