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

Function LuaGetTree

engine/gui/src/gui_script.cpp:4003–4030  ·  view source on GitHub ↗

get a node including its children * Get a node and all its children as a Lua table. * * @name gui.get_tree * @param node [type:node] root node to get node tree from * @return clones [type:table] a table mapping node ids to the corresponding nodes */

Source from the content-addressed store, hash-verified

4001 * @return clones [type:table] a table mapping node ids to the corresponding nodes
4002 */
4003 static int LuaGetTree(lua_State* L)
4004 {
4005 int top = lua_gettop(L);
4006 (void)top;
4007
4008 lua_newtable(L);
4009
4010 // Set meta table to convert string indices to hashes
4011 lua_createtable(L, 0, 1);
4012 lua_pushcfunction(L, HashTableIndex);
4013 lua_setfield(L, -2, "__index");
4014 lua_setmetatable(L, -2);
4015
4016 Scene* scene = GuiScriptInstance_Check(L);
4017 if (!lua_isnil(L, 1))
4018 {
4019 dmGui::HNode hnode;
4020 InternalNode* root = LuaCheckNodeInternal(L, 1, &hnode);
4021 PushNodeToTable(L, scene, root);
4022 }
4023 else
4024 {
4025 PushNodeListToTable(L, scene, scene->m_RenderHead);
4026 }
4027
4028 assert(top + 1 == lua_gettop(L));
4029 return 1;
4030 }
4031
4032 /*# resets all nodes to initial state
4033 * Resets all nodes in the current GUI scene to their initial state.

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.85
lua_createtableFunction · 0.85
lua_setfieldFunction · 0.85
lua_setmetatableFunction · 0.85
GuiScriptInstance_CheckFunction · 0.85
LuaCheckNodeInternalFunction · 0.85
PushNodeToTableFunction · 0.85
PushNodeListToTableFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected