NDDynamicSpawnerHUDVars

From Legends of Aria Admin and Modding Wiki
Revision as of 06:32, 9 December 2019 by Gizmo (talk | contribs)
Jump to: navigation, search

[Main] [Dynamic Spawners]

About HUDVars

HudVars is the way to tell the new HUD element what to display when players are near your dynamic spawner. The dynamic window function UpdateDynamicEventHUD is located in the hud.lua here is the function as of P8 release.

  • Title -
  • Description -
  • EndTime -
  • Stage -
  • MaxStage -
  • Progress -
function UpdateDynamicEventHUD(playerObj,vars)		
    local title = vars.Title or "Dynamic Event Title"
    local desc = vars.Description or "Dynamic Event Description."
    local endTime = vars.EndTime or nil
    local stage = vars.Stage or 0
    local maxStage = vars.MaxStage or 0
    local progress = vars.Progress or 0
    local dynWindow = DynamicWindow("DynamicEventHUD","",0,0,0,0,"Transparent","Top")
    dynWindow:AddLabel(0,30,title,0,0,24,"center",false,true,"SpectralSC-SemiBold")
    dynWindow:AddLabel(0,50,desc,0,0,18,"center",false,true,"SpectralSC-SemiBold")
    dynWindow:AddLabel(0,65,"["..COLORS.FloralWhite.."]".."Stage: [-]"..stage.." of ".. maxStage,0,0,18,"center",false,true ,"SpectralSC-SemiBold")

    if( endTime ) then
        local timeLeft = TimeSpanToWords(endTime:Subtract(DateTime.UtcNow), nil, {Seconds = true})
        dynWindow:AddLabel(0,80,timeLeft .. " Remaining",0,0,18,"center",false,true,"SpectralSC-SemiBold")
    end

    playerObj:OpenDynamicWindow(dynWindow)
end

function CloseDynamicEventHUD( playerObj )
    playerObj:CloseDynamicWindow("DynamicEventHUD")
end

HUDVars can also be assigned in the initializer of the template object using the dynamic_spawn_controller_universal module. See a template file Here