Difference between revisions of "NDDynamicSpawnerHUDVars"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
Line 1: Line 1:
 
<p style="width:60%;margin: 0 auto">[[NewDawnHome|[Main]]] [[NDDynamicSpawners|[Dynamic Spawners]]]</p>
 
<p style="width:60%;margin: 0 auto">[[NewDawnHome|[Main]]] [[NDDynamicSpawners|[Dynamic Spawners]]]</p>
 
<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</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">
 
<div style="width:60%;margin: 0 auto">
  <ObjectTemplate>
+
  function UpdateDynamicEventHUD(playerObj,vars)
  <ClientId>320</ClientId>
+
  <Name>[FF9500]Candle[-]</Name>
+
local title = vars.Title or "Dynamic Event Title"
  <SharedStateEntry name="Weight" type="int" value="1"/>
+
local desc = vars.Description or "Dynamic Event Description."
  <ObjectVariableComponent>
+
local endTime = vars.EndTime or nil
    <StringVariable Name="PluralName">Candles</StringVariable>
+
local stage = vars.Stage or 0
<BoolVariable Name="Worthless">true</BoolVariable>
+
local maxStage = vars.MaxStage or 0
<StringVariable Name="ResourceType">Candle</StringVariable>
+
  local progress = vars.Progress or 0
    </ObjectVariableComponent>
+
  <ScriptEngineComponent>
+
 
<LuaModule Name="stackable" />
+
  local dynWindow = DynamicWindow("DynamicEventHUD","",0,0,0,0,"Transparent","Top")
  </ScriptEngineComponent>
+
  dynWindow:AddLabel(0,30,title,0,0,24,"center",false,true,"SpectralSC-SemiBold")
  </ObjectTemplate>
+
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
 
</div>
 
</div>

Revision as of 06:22, 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.

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