Hi, I just started using Defols and I’m already making some progress with my game.
I need to implement a webview to open an HTML file but when if I try to run this snippet of code:
local function webview_callback(self, webview_id, request_id, type, data)
if type == webview.CALLBACK_RESULT_URL_OK then
-- the page is now loaded, let's show it
webview.set_visible(webview_id, 1)
elseif type == webview.CALLBACK_RESULT_URL_ERROR then
print("Failed to load url: " .. data["url"])
print("Error: " .. data["error"])
elseif type == webview.CALLBACK_RESULT_EVAL_OK then
print("Eval ok. Result: " .. data['result'])
elseif type == webview.CALLBACK_RESULT_EVAL_ERROR then
print("Eval not ok. Request # " .. request_id)
end
end
function init(self)
local webview_id = webview.create(webview_callback)
local request_id = webview.open(webview_id, "http://www.example.com", {hidden = true})
end
I get this error:
ERROR:SCRIPT: /main/main.script:18: attempt to index global ‘webview’ (a nil value)
stack traceback:
/main/main.script:18: in function </main/main.script:17>
What am I doing wrong?