- Documentation
- Client functions
- setBrowserFunction
Function
setBrowserFunction
Exposes a Lua function to a local page. In JavaScript you call it with await trilogy.call("name", ...) and get its result.
Syntax
bool setBrowserFunction(browser webBrowser, string name, function fn)Arguments
webBrowserbrowser- A local browser.
namestring- The name visible in JavaScript.
fnfunction- The Lua function, or
nilto remove it.
Returns
true on success.
Example
setBrowserFunction(browser, "getHealth", function()
return getElementHealth(localPlayer)
end)
<script>
trilogy.call("getHealth").then((hp) => {
document.getElementById("hp").textContent = Math.round(hp) + " HP";
});
</script>