Custom HUD Message Widget With Timer
23,759 Views
-
using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # The timer code custom_timer_device := class(creative_device): @editable HUDDevice : hud_message_device = hud_message_device{} # You can set the maximum time for the timer here. 0 = no max time @editable MaxTimeInSeconds : int = 60 # Runs when the device is started in a running game OnBegin<override>()<suspends>:void= StartTimer() StartTimer()<suspends>:void= # This timer uses seconds and will convert the seconds into minutes as it counts upwards #Create a variable to track how many seconds we've counted. We'll reset this one to 0 each time it reaches 60 var Seconds : int = 0 # Create a variable to track the total seconds passed. This will not reset and will be used to break out of timer loop var TotalSeconds : int = 0 #Create a variable to track how many minutes we've counted var Minutes : int = 0 #Start timer loop loop: # 1 time per second Sleep(1.0) #Increase the second counter set Seconds += 1 set TotalSeconds +=1 #If seconds is more than 59 if(Seconds > 59): #increase minute counter set Minutes +=1 # reset second counter set Seconds = 0 #Create a Hud message string to update our HUD with, and set the message to the result of this if statement HudMessage : string = if (Seconds < 10): "{Minutes}:0{Seconds}" else : "{Minutes}:{Seconds}" # Set the Hud message at the end of every loop (1x per second) HUDDevice.SetText(StringToMessage(HudMessage)) HUDDevice.Show() if(TotalSeconds >= MaxTimeInSeconds, MaxTimeInSeconds > 0): Print("Max Timer time reached!") break
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.