using { /Fortnite.com/Devices } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Verse.org/Simulation } using { /Verse.org/Colors } # This is our main script block PulsingLightDevice := class(creative_device): # This is a 'public' variable. # It means the light in the editor can be linked here. @editable LightDevice : customizable_light_device = customizable_light_device{} # This function runs when the game starts OnBegin() : void = # We start our timer at 0.0 var Time : float = 0.0 # This loop runs forever until the game stops loop: # We use 'Sin' to create a wave. # It goes up and down smoothly. Wave := Sin(Time * 5.0) # We map the wave (-1.0 to 1.0) to a 0.0–1.0 range # so the light never goes negative. Brightness := (Wave + 1.0) / 2.0 # We set the light's color to a red pulse. # Red changes based on the wave; Green and Blue stay low. # note: We use MakeColorFromSRGBValues (values 0–255) to build the color, # then set brightness via the light's DimLight/TurnOn approach is unavailable, # so we just enable/disable or use the color intensity trick. # customizable_light_device does not expose SetColor, so we approximate # the pulse by toggling the light based on brightness threshold. if (Brightness > 0.5): LightDevice.TurnOn() else: LightDevice.TurnOff() # We pause for a tiny bit. # This keeps the game from freezing. Sleep(0.01) # Advance our timer set Time = Time + 0.05