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
| 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 | * |
nothing calls this directly
no test coverage detected