Problems with DrawHp

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Ear1h
Posts: 6
Joined: Fri May 26, 2023 5:34 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel (Modern GZDoom)

Problems with DrawHp

Post by Ear1h »

While learning with Hud, I had a problem with the DrawHealthBar function
Spoiler:
However, when I start it up, I get the following error:
"Can't play function DrawHealthBar from ui context"
"Can't call ui function DrawImage from play context (not readable)"
User avatar
ramon.dexter
Posts: 1437
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Problems with DrawHp

Post by ramon.dexter »

Show your whole statusbar code. It's hard to decide anything from these snippets.
Ear1h
Posts: 6
Joined: Fri May 26, 2023 5:34 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel (Modern GZDoom)

Re: Problems with DrawHp

Post by Ear1h »

ramon.dexter wrote: Sat May 27, 2023 3:19 am Show your whole statusbar code. It's hard to decide anything from these snippets.
Here's all the code
Spoiler:
Jarewill
 
 
Posts: 1641
Joined: Sun Jul 21, 2019 8:54 am

Re: Problems with DrawHp

Post by Jarewill »

That error appears because you didn't specify a ZScript version.
To fix it, add this line to the beginning of your ZScript file: version "4.0", replacing 4.0 with your target GZDoom version.

Also if you aren't planning on making another class inheriting from your HUD and overriding your functions, you don't need to make DrawHealthBar a virtual function.
Ear1h
Posts: 6
Joined: Fri May 26, 2023 5:34 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel (Modern GZDoom)

Re: Problems with DrawHp

Post by Ear1h »

Jarewill wrote: Sat May 27, 2023 5:52 am That error appears because you didn't specify a ZScript version.
To fix it, add this line to the beginning of your ZScript file: version "4.0", replacing 4.0 with your target GZDoom version.

Also if you aren't planning on making another class inheriting from your HUD and overriding your functions, you don't need to make DrawHealthBar a virtual function.
It's really working, thanks

Return to “Scripting”