Custom element registration
This commit is contained in:
28
assets/pages/test-page.lua
Normal file
28
assets/pages/test-page.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
TestPage = {}
|
||||
|
||||
local maxHp = 100
|
||||
local currentHp = 100
|
||||
|
||||
function TestPage.Damage(event)
|
||||
|
||||
currentHp = currentHp - 5
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
local target = document:GetElementById("hp-bar")
|
||||
|
||||
if target then
|
||||
target:SetAttribute("current", currentHp)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TestPage.Heal(event)
|
||||
currentHp = currentHp + 5
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
local target = document:GetElementById("hp-bar")
|
||||
|
||||
if target then
|
||||
target:SetAttribute("current", currentHp)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user