Scripts / How do you hide a custom HUD while watching a storyzone video?

Author
Message
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 27th Feb 2017 15:37 Edited at: 27th Feb 2017 15:39
I would like to hide my custom HUD while the player is watching a video at the start of the level. The player-start marker has a story zone over it so the player starts the level by watching a video. While the video plays at the beginning of the level, part of the custom HUD is continually visible (see picture below).

I have worked on changing lines in my custom HUD script several different ways, and still can't figure out how to get this to work without getting an error message while loading a test game (see error message picture below).

I tried to put the following lines in my custom HUD script:

if g_Entity[e]['storyzone']==1 then
HideHuds(e)
elseif g_Entity[e]['storyzone']==0 then
ShowHuds(e)

This gives an error message (see picture below). No matter how I arrange the end command, it still gives errors or still shows the partial HUD.

Here are some forum threads I have looked at for suggestions:

Hide HUD - https://forum.game-guru.com/thread/216904

Delay HUD - https://forum.game-guru.com/thread/213106

HideHud & ShowHud - https://forum.game-guru.com/thread/211084

See the pictures below to see the partial HUD showing up (during the video), the HUD in the game, and the error message I am getting.

Any help is appreciated...

Thanks

Attachments

Login to view attachments
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Feb 2017 17:06 Edited at: 27th Feb 2017 17:07
HideHuds()
and
ShowHuds()
only hide and show the default hud, not custom ones...
you just need to place the sprites you used for your hud off screen for the video and then move them back once it's finished playing, this can be done with a timer (same length as the video) and a check to see if the video was skipped (not sure what button is to skip now, maybe left click)

edit, a quick way that might work is to simply move the script that loads the custom hud onto an object that is loaded later than the zone used to play the video (i.e. custom hud entity has a higher entity number than the zone)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Feb 2017 18:26
If you set the sprite to depth of 100 it sits behind video, smallg might be able to tell you how to do that, I forget right now and i'm in the middle of installing my new PC so don't have my notes to check.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 27th Feb 2017 18:30
Easiest way is to just position the HUDs offscreen until you want them again. I'm bound to have covered it here.


SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 28th Feb 2017 02:19
I have been working hard on this problem all day long and can't figure it out... My brain is burning out and giving me a headache.

@ DVader - I watched your video, but couldn't figure out where you showed how to put the HUD off the screen... unless it is so vastly different then my script that it's nearly totally incompatible with my script.
PM
gd
8
Years of Service
User Offline
Joined: 21st Jul 2016
Location: Small Darkroom with no red light
Posted: 28th Feb 2017 10:18 Edited at: 28th Feb 2017 10:39
Hi Len the man, without seeing your code it is hard to guess how many sprites you are using and where to put the code. But as the other have said; just move them to a lower depth or off screen with something like this.

SetSpritePosition ( hudSprite , 200 , 200 ) -- just change this to your sprite hud image for "hudSprite" to whatever.
-- then back to the original screen location.
SetSpritePosition ( hudSprite , xpos , ypos ) -- xpos and ypos are your x and y screen locations.
or
SetSpriteDepth ( hudSprite , 94 ) -- between 100-1 -- 100 being the lowest depth and 1 being the top depth and so on.

Edit - In one of your images I notice the image is still on screen this maybe because you need to change the (x, y) position greater than the image size. When I first started using HUD's I had the same issue. So just change the (x, y) of screen position to greater than 200 for each (x, y).

Also keep in-mind if you want text on top of your sprite to use the SetSpritePosition, SetSpriteDepth off screen to start then use PasteSpritePosition so it is lower than the text.

Example



Also what DVader is using is a toggle script to switch the HUD on and off using keys. Well what it really dose is creates the HUD sprite image then deletes the HUD sprite image every time you press the key assigned to the script.
Dark Base 900 Pro OJ: Rampage V Ed.10, i7 6950x non-OC, DDR4-3333 64 GB RAM, Win 10/64, Asus Strix GeForce 1080 x 2 SLI mode, Water cooled with an old Victorian cast iron radiator and a industrial leather belt driven fan - That's what you call Steampunked.

Laptop - M17xR3


A new competition running for GG
PM
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 28th Feb 2017 13:19 Edited at: 28th Feb 2017 14:23
Thanks gd... I will give it a try.

Update:

I still can't get it to work, and I can't figure it out... Here is the script...


PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Feb 2017 15:06
You don't need a toggle or anything like that, you just need set the sprite to that furthest layer back and the video will cover it up.

just add:

SetSpriteDepth ( mySprite , 100 )

(mySprite being whatever you designated as the sprites name in CreateSprite)

in the sprite creation section.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 28th Feb 2017 22:28
For some unknown reason, I set it to 100, and it still has the same problem.

This has got me baffled.
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Feb 2017 22:36
Quote: "For some unknown reason, I set it to 100, and it still has the same problem."


Hmn, no idea why, it worked on my hud script for my videos.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 01:05 Edited at: 1st Mar 2017 01:05
I'm thinking that part of the problem might be that part of the script taps into the globals, which may be over-riding everything else. This will make part of the script visible no matter what any other script or line in the script states.

So I might need to use other HUD's listed here in the forum that don't seem to tamper with globals... I will simply alter the position numbers so it looks like what I previously had, but without altering the globals.

Thanks for the help and suggestions everybody. I sincerely appreciate the help.

At least I'm learning... I'm learning to do some scripting... and at least I'm getting to some good conclusions.
PM
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 01:43
Wow Belidos! Your HUD script works really nice... I love it. I altered the picture and the location to what I wanted, but it's really nice.

I also put in a story-zone with video and it was able to hide the HUD while the video was playing.

I think I'm going in a much better direction now.

Thank you very much. I sincerely appreciate you sharing that script and advice here in the forum.

I guess I will simply add some more HUD's in order to have a HUD for health and ammo like I had before. I guess I can attach each one of the 3 HUD's to 3 different rock entities.

Thanks again...

Attachments

Login to view attachments
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 1st Mar 2017 09:48 Edited at: 1st Mar 2017 09:49
You can put all three in one script.

Here you go, same procedure as before, you will need an ammo.png, health.png, and lives.png in your scriptbank/images folder.

It's written so you can easily change the locations etc in the HUD Locations and Sizes section,

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.

Attachments

Login to view attachments
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 13:29
Wow! Thanks again Belidos. You are very kind and generous.

Is there a way to change the numbers in the HUD to black?
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 1st Mar 2017 13:56 Edited at: 1st Mar 2017 13:58
Change:
TextCenterOnX(heart_tex_posx,heart_tex_posy,heart_text_size,""..g_PlayerHealth) --.." / "..g_max_PlayerHealth)

to

TextCenterOnXColor(heart_tex_posx,heart_tex_posy,heart_text_size,""..g_PlayerHealth,1,1,1) -- .." / "..g_max_PlayerHealth)

and

TextCenterOnX(lives_tex_posx,lives_tex_posy,lives_text_size,""..g_PlayerLives)

to

TextCenterOnXColor(lives_tex_posx,lives_tex_posy,lives_text_size,""..g_PlayerLives,1,1,1)

and

TextCenterOnX(ammo_tex_posx,ammo_tex_posy,ammo_text_size,""..g_PlayerGunAmmoCount.." / "..g_PlayerGunClipCount)

to

TextCenterOnXColor(ammo_tex_posx,ammo_tex_posy,ammo_text_size,""..g_PlayerGunAmmoCount.." / "..g_PlayerGunClipCount,1,1,1)

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.

Attachments

Login to view attachments
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 16:25 Edited at: 1st Mar 2017 16:51
Thanks again Belidos.

Your help is greatly appreciated.

Update:

For some reason this is causing the test game to crash. I will see if I can look through it and see if I can figure out why.
PM
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 18:33 Edited at: 1st Mar 2017 18:35
I got the three HUD's working with black numbers.

I had to change some of the lines in the scripts to get them to work and show black text.

I slightly changed the ammo script since it called for counting gun clips and my map only has revolvers and bullets.

Original:



My re-make:



The scripts seemed to have a problem calling the ,1,1,1 at the end of all the lines that called for text color.



You can see the corrected HUD (with black text) at the bottom of the attached picture:

Attachments

Login to view attachments
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 1st Mar 2017 19:20 Edited at: 1st Mar 2017 19:25
That's odd, it worked perfectly on my machine, and the attachment was directly uploaded from my script bank, it should have worked fine.

Did you download the attachment or cop paste the lines from the explanation? Copy paste from the forums is a little buggy, it adds invisible characters at the end of the lines, its best to download attachments or manually type them out.

Glad you got it working though.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
Len the man
9
Years of Service
User Offline
Joined: 12th Jun 2015
Location:
Posted: 1st Mar 2017 21:16
I used the download you posted, but for some reason it kept crashing and never would go into the test game. It kept saying that there was error 301 (see picture below).

Attachments

Login to view attachments
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 1st Mar 2017 23:51
Hmn that is strange, I've retested it on my machine and it's working perfectly, I've deleted the old attachment and uploaded it to that post again, maybe it was corrupted on upload, see if that works.

(btw text size is 1 to 7, and it's not really size as such it's different fonts and sizes)

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.

Login to post a reply

Server time is: 2024-12-23 03:10:42
Your offset time is: 2024-12-23 03:10:42