[VX ACE] QUICK CONDITIONAL BRANCH CODE QUESTION
Posts
Pages:
1
Hello again! I once again have what's probably a very basic scripting question. ^^;;
I've noticed that VX Ace's Conditional Branch function, while usually great, can also be quite limited. I'm trying to get a conditional branch that will do something if Character #1's HP is less than 47%. I can't seem to do this with the standard options, but I notice that there's a "script" option on the last tab.
Would a line of script work that would trigger the conditional branch if Actor1's HP is less than 47%? What would the script look like?
Thanks much in advance, and sorry again for being such a scripting dummy XD
I've noticed that VX Ace's Conditional Branch function, while usually great, can also be quite limited. I'm trying to get a conditional branch that will do something if Character #1's HP is less than 47%. I can't seem to do this with the standard options, but I notice that there's a "script" option on the last tab.
Would a line of script work that would trigger the conditional branch if Actor1's HP is less than 47%? What would the script look like?
Thanks much in advance, and sorry again for being such a scripting dummy XD
It might look something like...
...that?
SCRIPT ()$game_variables[1] = 100 * $game_actors[1].hp / $game_actors[1].maxhp
CONDITIONAL BRANCH (VAR001 < 47)
...that?
You can do it using just the single script line in the conditional branch function:
RGSS is nice enough to follow Order of Operations. =)
(And apologies - I'm not trying to show anyone up. I used to "spaghetti code" and have since had it drilled into my head to cut down the number of lines I need to use wherever possible. ;_;)
$game_actors[1].hp < ($game_actors[1].maxhp/100 * 47)
RGSS is nice enough to follow Order of Operations. =)
(And apologies - I'm not trying to show anyone up. I used to "spaghetti code" and have since had it drilled into my head to cut down the number of lines I need to use wherever possible. ;_;)
Thank you both very much, once again :D
EDIT: Both of these are giving me error messages ;_;
To make sure it wasn't because of any scripts I have, I tried it in a new game and got the same results.
For Marrend's, I get:

For Travio's:

If need-be, I can provide screenshots of how I set them up just in case I did something bone-headed.
EDIT: Both of these are giving me error messages ;_;
To make sure it wasn't because of any scripts I have, I tried it in a new game and got the same results.
For Marrend's, I get:
For Travio's:
If need-be, I can provide screenshots of how I set them up just in case I did something bone-headed.
Try $game_actors[1].mhp instead of $game_actors[1].maxhp. Travio's implementation should work better, at the very least.
*Edit: I temporarily forgot that it even was "mhp" for VX Ace.
*Edit: I temporarily forgot that it even was "mhp" for VX Ace.
Yup - exact same thing here. I've been working in XP all morning, where it uses maxhp - mhp is, in fact, the correct one. I should probably double check my work sometimes. >_<
(Speaking of working in XP, VX Ace has made so many things so much nicer that I'm really struggling working with XP, hah.)
(Speaking of working in XP, VX Ace has made so many things so much nicer that I'm really struggling working with XP, hah.)
Pages:
1















