Your version looks fine, but I think Ive spotted it.
Your entity3d 'hero' is undefined until you initialise it in main.
But your panel HealthPan is active immediately, BEFORE hero gets initialised,
and goes splat trying to display an undefined variable.
I cant see an easy way out of this, other than having a duplicate global health
variable to display with, or using pan_create tp create the HealthPan on-the-fly after hero has been initialised.