ID:264301
 
Code:
mob
var
Health = 100
maxHealth = 100
Stat()
statpanel("Stats")
stat("Health:","[Health] / [maxHealth] ([Health/maxHealth*100]%)")


Problem description:
For some reason, when I compile and run the game, the 'Health' var is null. How do I know this? The Stats tab, doesn't show it. The Stats tab shows " / 100 (0%)" exactly. So for some reason, Health is being nulled out by something. Any clues as to how/why?
Mizukouken Ketsu wrote:
Problem description:
For some reason, when I compile and run the game, the 'Health' var is null. How do I know this? The Stats tab, doesn't show it. The Stats tab shows " / 100 (0%)" exactly. So for some reason, Health is being nulled out by something. Any clues as to how/why?

Most likely, this is happening when you load your character from a savefile.

Lummox JR
In response to Lummox JR
No savefiles involved. I'm creating brand new characters each time.

EDIT
I even deleted the savefiles that existed. Still nothing.
In response to Mizukouken Ketsu
If savefiles are not involved, then it has to be the more mundane answer: Something is changing the Health var at some point.

The easiest way to diagnose this will be to search your code for any place where the Health var is used at all and go through them with a fine-toothed comb. If that turns up nothing, also look for any use of the vars[] list. If that still turns up nothing, go back to the savefile thing and put in some basic debugging code in Read() to make sure that Health is in fact not being changed by a load.

The bottom line is, the var is being changed somewhere. The only things that can change a var are assignment operators, using assignments with the vars[] list, or loading new values en masse from a savefile.

Lummox JR
In response to Lummox JR
It's not just the Health var though :\ It's any var I assign that has a second value. Health - maxHealth, Stamina - maxStamina, etc.
In response to Mizukouken Ketsu
mob/Login()
src.Health = initial(Health)
..()

Dunno try that at login and see what it does.
In response to Yash 69
That worked! o.o

EDIT
Just realized that since I have the ability for players to be able to increase their Health and whatnot, wouldn't initial() keep resetting their stats?
In response to Mizukouken Ketsu
Indeed. What you need to do is find the source of the problem, instead of do such a thing to work around it. Lummox already talked about this.
In response to Mizukouken Ketsu
It's not to be kept in. It proves that your Health is being changed somewhere else in the code, apparently in Login().
In response to Kaiochao
Kaiochao wrote:
It's not to be kept in. It proves that your Health is being changed somewhere else in the code, apparently in Login().

Adding that line to the beginning of Login() wouldn't affect the outcome if the Login() proc was resetting the var. The reset is happening before Login() is called, but after New(), which is entirely consistent with my theory that a savefile loading is responsible for the problem.

Lummox JR
In response to Lummox JR
But I told you already. There aren't any savefiles involved. I even took the system out completely. It's still being screwy >.<