Difference between revisions of "NDDynamicSpawnerHUDVars"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
<p style="color: #DDDD88;font-size: 22px;width:60%;margin: 0 auto">About HUDVars</p>
 
<p style="color: #DDDD88;font-size: 22px;width:60%;margin: 0 auto">About HUDVars</p>
 
<p style="width: 60%;margin: 0 auto">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.</p>
 
<p style="width: 60%;margin: 0 auto">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.</p>
 +
<div style="width:60%;margin: 0 auto">
 +
*Title -
 +
*Description -
 +
*EndTime -
 +
*Stage -
 +
*MaxStage -
 +
*Progress -
 +
</div>
 
<div style="width:60%;margin: 0 auto">
 
<div style="width:60%;margin: 0 auto">
 
  function UpdateDynamicEventHUD(playerObj,vars)
 
  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")
 
   
 
   
local title = vars.Title or "Dynamic Event Title"
+
    if( endTime ) then
local desc = vars.Description or "Dynamic Event Description."
+
        local timeLeft = TimeSpanToWords(endTime:Subtract(DateTime.UtcNow), nil, {Seconds = true})
local endTime = vars.EndTime or nil
+
        dynWindow:AddLabel(0,80,timeLeft .. " Remaining",0,0,18,"center",false,true,"SpectralSC-SemiBold")
local stage = vars.Stage or 0
+
    end
local maxStage = vars.MaxStage or 0
 
local progress = vars.Progress or 0
 
 
   
 
   
+
    playerObj:OpenDynamicWindow(dynWindow)
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
 
  end
 
   
 
   
 
  function CloseDynamicEventHUD( playerObj )
 
  function CloseDynamicEventHUD( playerObj )
playerObj:CloseDynamicWindow("DynamicEventHUD")
+
    playerObj:CloseDynamicWindow("DynamicEventHUD")
 
  end
 
  end
 +
</div>
 +
<div style="width:60%;margin: 0 auto">
 +
HUDVars can also be assigned in the initializer of the template object using the <i>dynamic_spawn_controller_universal</i> module. See a template file [[NDDynamicSpawners|Here]]
 
</div>
 
</div>

Latest revision as of 06:33, 9 December 2019

[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