ExecuteWebJS: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|ExecuteWebJS(web, Javascript)}} {{FuncParameters}} {{FuncParam|web|__EDIT_ME__}} {{FuncParam|Javas..." |
No edit summary |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Executes Javascript in the WebUI. (Make sure to first call this after all your js is loaded by sending an event from js.) | ||
Wait until [[OnWebLoadComplete]] was called.}} | |||
{{FuncSyntax|ExecuteWebJS(web, Javascript)}} | {{FuncSyntax|ExecuteWebJS(web, Javascript)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|web| | {{FuncParam|web|The web identifier.}} | ||
{{FuncParam|Javascript| | {{FuncParam|Javascript|The Javascript source.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|This function returns '''true''' if the web identifier is found. It does not return the return values from JS as this whole process is asynchronous.}} | ||
== Example == | == Example == | ||
Example from the debug package: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/debug/debug_c.lua | |||
<syntaxhighlight lang="Lua> | |||
function UpdateLocalInfo() | |||
local x, y, z = GetPlayerLocation() | |||
local h = GetPlayerHeading() | |||
local data = "<br>LOCAL (ID: " .. GetLocalPlayer() .. ")<br>" | |||
data = data .. "Loc: " .. x .. ", " .. y .. ", " .. z .. ", " .. h .. "<br>" | |||
data = data .. "Movement: " .. GetPlayerMovementMode() .. ", " .. GetPlayerMovementSpeed() .. "<br>" | |||
ExecuteWebJS(webui, "SetLocalInfo('"..data.."');") | |||
end | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{WebEvents}} |
Latest revision as of 20:33, 30 August 2020
Description
Executes Javascript in the WebUI. (Make sure to first call this after all your js is loaded by sending an event from js.)
Wait until OnWebLoadComplete was called.
Syntax
ExecuteWebJS(web, Javascript)
Parameters
- web
The web identifier. - Javascript
The Javascript source.
Return Value
- This function returns true if the web identifier is found. It does not return the return values from JS as this whole process is asynchronous.
Example
Example from the debug package: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/debug/debug_c.lua
function UpdateLocalInfo()
local x, y, z = GetPlayerLocation()
local h = GetPlayerHeading()
local data = "<br>LOCAL (ID: " .. GetLocalPlayer() .. ")<br>"
data = data .. "Loc: " .. x .. ", " .. y .. ", " .. z .. ", " .. h .. "<br>"
data = data .. "Movement: " .. GetPlayerMovementMode() .. ", " .. GetPlayerMovementSpeed() .. "<br>"
ExecuteWebJS(webui, "SetLocalInfo('"..data.."');")
end