HTML5 platform specific functions.
The following functions are only available on HTML5 builds, the html5.*
Lua namespace will not be available on other platforms.
run JavaScript code, in the browser, from Lua
Executes the supplied string as JavaScript inside the browser.
A call to this function is blocking, the result is returned as-is, as a string.
(Internally this will execute the string using the eval()
JavaScript function.)
code -
string Javascript code to run
result -
string result as string
local res = html5.run("10 + 20") -- returns the string "30" print(res) local res_num = tonumber(res) -- convert to number print(res_num - 20) -- prints 10