MCPcopy Create free account
hub / github.com/defold/defold / Sys_OpenURL

Function Sys_OpenURL

engine/script/src/script_sys.cpp:657–683  ·  view source on GitHub ↗

open url in default application * Open URL in default application, typically a browser * * @name sys.open_url * @param url [type:string] url to open * @param [attributes] [type:table] table with attributes * * `target` * - [type:string] [icon:html5]: Optional. Specifies the target attribute or the name of the window. The following values are supported:

Source from the content-addressed store, hash-verified

655 * ```
656 */
657 static int Sys_OpenURL(lua_State* L)
658 {
659 DM_LUA_STACK_CHECK(L, 1)
660 int top = lua_gettop(L);
661 const char* url = luaL_checkstring(L, 1);
662 dmSys::Result result;
663 if (top > 1)
664 {
665 luaL_checktype(L, 2, LUA_TTABLE);
666 lua_pushvalue(L, 2);
667
668 lua_getfield(L, -1, "target");
669 const char* target = lua_isnil(L, -1) ? 0 : luaL_checkstring(L, -1);
670 lua_pop(L, 1);
671
672 lua_pop(L, 1);
673 result = dmSys::OpenURL(url, target);
674 }
675 else
676 {
677 result = dmSys::OpenURL(url, 0);
678 }
679
680 lua_pushboolean(L, result == dmSys::RESULT_OK);
681
682 return 1;
683 }
684
685 /*# loads resource from game data
686 *

Callers

nothing calls this directly

Calls 6

lua_gettopFunction · 0.85
luaL_checktypeFunction · 0.85
lua_pushvalueFunction · 0.85
lua_getfieldFunction · 0.85
lua_pushbooleanFunction · 0.85
OpenURLFunction · 0.50

Tested by

no test coverage detected