Can now add a lua file with the same name as a page for page-scoped lua functionality
This commit is contained in:
17
assets/pages/lua-test.lua
Normal file
17
assets/pages/lua-test.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
LuaTest = {}
|
||||
|
||||
local counter = 0
|
||||
|
||||
function LuaTest.Test(event)
|
||||
counter = counter + 1
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
|
||||
local target = document:GetElementById("lua-counter")
|
||||
if target then
|
||||
target.inner_rml = "Lua Counter: " .. counter
|
||||
end
|
||||
|
||||
print("Lua counter incremented to: " .. counter)
|
||||
|
||||
end
|
||||
@@ -2,4 +2,8 @@
|
||||
<h1>Lua test page</h1>
|
||||
<p>This button uses <code>NavigateTo('about')</code> lua code instead of a registered C++ event</p>
|
||||
<button onclick="NavigateTo('about')">Go to About Page</button>
|
||||
|
||||
<p>This button calls <code>LuaTest.Test()</code> from the scoped `lua-test.lua` file</p>
|
||||
<button onclick="LuaTest.Test(event)">Click me!</button>
|
||||
<p id="lua-counter"></p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user