Setting variables to character stats not working

Setting variables to player's HP, ATK or other stats does not seem to work at all.  They always show as 0 when displayed in text with \v[n] -- e.g. setting variable 0001 to Zack's HP, and then using \v[1] in a Show Text command immediately thereafter results in 0 being shown even though he has non-0 HP at that time) .

Likewise any conditional branches that test variables that have been set to stats behave as if the stats are always 0.  Others seeing this?
Can you show a screenshot? Any chance you have something else running, on parallel process, that's resetting it?
I just tested this quickly on my program, seem's to be working fine.

drVSSmz.png


EaLY6CD.png
Was just about to say the same and post a similar pair of screenshots 😀

It certainly works fine for me too. I'd make sure to double check the values you're inputting in your \v[n] text? A screenshot of your event window would really help though.
Ok, I got it working in two different cases that were giving me trouble.

First, I wanted to make an event that represented a monster disappear from the map if the party was successful in battle with it.  Since RM2k3 doesn't have any direct "Battle won" condition, I wanted to check XP before and after battle to test for success. So I had this two-tab set-up for the event:

2z74emu.png


kdwj1k.png


The second tab will run immediately after a party-victorious battle, but the "post-battle XP" will be the same as the "pre-battle XP" (0 in my testing since it's the party's first battle).

2w3qsuf.png


 What I discovered is that a parallel process set up this way will run after a battle ends but apparently before the XP value is actually updated for the party.  The solution is to just assign and test the "post-battle XP" all in the first tab, directly after the battle processing event (which is simpler anyway), like so:

2lncs9l.jpg


The other case was driving me mad, and I don't quite understand the fix.

I had two near identical events that would do a Show Text displaying Zach's HP and ATK.  One would always show 0 for the stats, the other correctly display them.  They were definitely referencing the same variable #s (3 and 4).  But when I looked closely at the events, i saw the name of the variables were different in the two events where I assigned.  Between making the two events I had *renamed* the variables, and I guess this can be a gotcha for older events referencing the renamed variable?  See below:

28lxsgi.jpg


2py5jlc.jpg


The second one, where the control variable command show the new/current names of the variables, correctly displays the stats in the Show Text command, the first event displays the 0 for both.  I deleted the variable assignment commands in the first event, and re-added them (now they show the new names), and now the first event works too. I know I also changed the max number of variables at some point -- possibly between creating the two events, so maybe that also/instead can cause variable references in events made before that change to go awry?  Something to look out for? (Ie always change the max # of variables, etc when you first create a project, before actually creating the variables?)
Sorry to tell you this, but it has a "battle won" condition. xD

PmxVv8n.png


If you put anything in the marked "Conditional Branches" you get a "If battle won" thing and whatever else you may wanted.
Argh, I didn't know that became available in that Conditional Branch - I assumed that "If Escape" box only applied to literally escaping without completing, not completing a battle successfully.  That's much simpler, thanks!

Still don't quite understand what went wrong with the second case, though - do you have to be careful about re-naming variables? Increasing the max number? Both?
Also, as general advice. Something like your XP thingy, you should do stuff like this in a single common event. Then you can just call the event when it is needed instead of asking after each and every battle. And if you want to change something you only have to change the single common event and not all events where you did this.
Actually, if you leave everything default, the event will only continue if you defeat the enemy anyway, since you can't escape and will get a Game Over if you die.
Oh, yeah, totally forgot about that. If you do it like this, you can't escape from a battle. So it will be a kill-or-be-killed fight. Useful for bosses, but definitly not for normal enemies.
Thanks, that's all very helpful.  Please see my questions above about the 2nd, non-combat case - still confused on the best way to avoid that problem.
The problem is that you are confusing these two settings:

2015_04_27_11_02_09_event_editor___id_0001.png


The first one addresses a variable directly, like, "Write something into variable #1".

The second one addresses a variable indirectly through another variable, like "Write something into the variable whose ID I stored in variable #1".

In your case, in one of your events you are not storing something in var. #3, but instead the RM reads var. #3 first - let's assume it's 0 at the time - and then tries writing into var. #0 (which does nothing because there is no var. #0).
Ahh, gotcha. The offending commands were deleted during my 'fix', so I can't double-check them, but that must be what I did! Thanks, all. 😀 This can be closed now.

Original thread: https://forums.rpgmakerweb.com/threads/setting-variables-to-character-stats-not-working.39298/