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

Function LuaGetIndex

engine/gui/src/gui_script.cpp:1018–1045  ·  view source on GitHub ↗

gets the index of the specified node * * Retrieve the index of the specified node among its siblings. * The index defines the order in which a node appear in a GUI scene. * Higher index means the node is drawn on top of lower indexed nodes. * * @name gui.get_index * @param node [type:node] the node to retrieve the id from * @return index [type:number] the in

Source from the content-addressed store, hash-verified

1016 * ```
1017 */
1018 static int LuaGetIndex(lua_State* L)
1019 {
1020 int top = lua_gettop(L);
1021 (void) top;
1022
1023 Scene* scene = GuiScriptInstance_Check(L);
1024
1025 HNode hnode;
1026 InternalNode* n = LuaCheckNodeInternal(L, 1, &hnode);
1027
1028 uint32_t index = 0;
1029 uint16_t i = scene->m_RenderHead;
1030 if (n->m_ParentIndex != INVALID_INDEX)
1031 {
1032 InternalNode* parent = &scene->m_Nodes[n->m_ParentIndex];
1033 i = parent->m_ChildHead;
1034 }
1035 while (i != INVALID_INDEX && i != n->m_Index)
1036 {
1037 ++index;
1038 i = scene->m_Nodes[i].m_NextIndex;
1039 }
1040 lua_pushnumber(L, index);
1041
1042 assert(top + 1 == lua_gettop(L));
1043
1044 return 1;
1045 }
1046
1047 /*# deletes a node
1048 *

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
GuiScriptInstance_CheckFunction · 0.85
LuaCheckNodeInternalFunction · 0.85
lua_pushnumberFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected