Clearing HudMessage doesn't work

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!)
r3v3n93
Posts: 33
Joined: Tue Jun 09, 2020 7:16 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)
Location: North Korea

Clearing HudMessage doesn't work

Post by r3v3n93 »

Code: Select all

int controller = 0;

script "Countdown" (void)
{
	SetActivator(0, AAPTR_PLAYER1);
	Hudmessage(s:"The main core is going to be shut down in T-60 seconds"; HUDMSG_PLAIN, 2, CR_SAPPHIRE, 0.5, 0.4, 7.6);
	Delay(280);
	GiveInventory("Time", 60);
	ACS_NamedExecute("RealCountDown", 0);
}



Script "RealCountDown" (void)
{
	SetActivator(0, AAPTR_PLAYER1);
	controller = 0.0;
	ACS_NamedTerminate("Objective", 0);
	int second = CheckInventory("Time");
	while(second > 0)
	{

		SetHudSize(640, 480, 1);
	    TakeInventory("Time", 1);
		second = CheckInventory("Time");
		HudMessage(s:"New Objective:"; HUDMSG_PLAIN, 0, CR_RED, 10.0, 80.0, 1.0);
		HudMessage(s:"Survive For:"; HUDMSG_PLAIN, 0, CR_white, 0.0, 90.0, 1.0);
	    HudMessage(d:second, s:"   seconds"; HUDMSG_PLAIN, 0, CR_white, 0.0, 100.0, 1.0);
	    delay(35);
    }
	Thing_Destroy(100, 1);
	Terminate;
}

Script "Objective" (void)
{
		SetHudSize(640, 480, 1);
		HudMessage(s:"Objective:"; HUDMSG_PLAIN, 0, CR_RED, 0.0, 80.0, controller);
		HudMessage(s:"Find a way to break brainwash"; HUDMSG_PLAIN, 0, CR_WHITE, 67.0, 90.0, controller);
		HudMessage(s:"Do not kill Friendlies"; HUDMSG_PLAIN, 0, CR_WHITE, 29.0, 100.0, controller);
}
So what I'm trying to do here is when "RealCountDown" executes, "Objective" will be terminated and Hudmessage inside it will be turned off either. However it seems that it doesn't work, and what I got was "Realcountdown" being stacked under "Objective". I tried making "Objective" work with while loop, but that doesn't work either.
r3v3n93
Posts: 33
Joined: Tue Jun 09, 2020 7:16 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)
Location: North Korea

Re: Clearing HudMessage doesn't work

Post by r3v3n93 »

by the way, if you can't comprehend my writing, which is shitty,

https://drive.google.com/file/d/1_9gESi ... sp=sharing

there you go. it's the map.
User avatar
ramon.dexter
Posts: 1241
Joined: Tue Oct 20, 2015 12:50 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Clearing HudMessage doesn't work

Post by ramon.dexter »

You'set timeout for the hudmsg for 0.0, that means 'stay forever'. If you wan to clear such hudmessage, you have to again call it, empty ( without text).
User avatar
Virathas
Posts: 220
Joined: Thu Aug 10, 2017 9:38 am

Re: Clearing HudMessage doesn't work

Post by Virathas »

There's is a few more issues with the scripts:
1) The player actually has 68 seconds until "reactor shut down" - I do not believe this is intentional.
2) Terminating the "Objective" script does nothing. While have never used a terminate script, it will only affect scripts that are running. The Objective script ran only once and set the hud message display to permanent (as ramon noted)

To have things probably working the same as you had, you could edit the Objective script to be inside a "loop" with a "delay(1)" and have the hud message display for as short as possible. That way, the terminate script should work as you'd expect
r3v3n93
Posts: 33
Joined: Tue Jun 09, 2020 7:16 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)
Location: North Korea

Re: Clearing HudMessage doesn't work

Post by r3v3n93 »

Thank's for the answers guys. You guys inspired me.

To Virathas
1) The player actually has 68 seconds until "reactor shut down" - I do not believe this is intentional.
└It was intentional. I wanted to activate the timer as soon as the message ends. But eventually, I changed it to begin as soon as the message starts because of the difficulty.
2) Terminating the "Objective" script does nothing. While have never used a terminate script, it will only affect scripts that are running. The Objective script ran only once and set the hud message display to permanent (as ramon noted)
└ I wanted to make sure that the script is shut down completely. Also, what I wanted to implement was when "RealCountDown" changes the value of integer 'controller', hudmessages that contain controller would be changed as well.

To ramon.dexter

You'set timeout for the hudmsg for 0.0, that means 'stay forever'. If you wan to clear such hudmessage, you have to again call it, empty ( without text).
└ I set it 0.0 because 0.1 didn't work either, or I am just dumb.

My English is a$$. Sorry.
User avatar
ramon.dexter
Posts: 1241
Joined: Tue Oct 20, 2015 12:50 pm
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Clearing HudMessage doesn't work

Post by ramon.dexter »

No, you'not dumb. The hudmessages are little bit tricky to master. As virathas said, you need to either insert a really short timespan and use while loop. Or, as I said, you need to call the hudmessages once again in the 'sclosing script', just without any text entered.
Something like this (copied from the first script):

Code: Select all

Hudmessage(s:""; HUDMSG_PLAIN, 2, CR_SAPPHIRE, 0.5, 0.4, 7.6);
Using it this way, it will remove the previously drawn hudmessage with tag/number/ID '2'. Believe me, this is the best way if you want precise control on how long it will stay onscreen.

Return to “Scripting”