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

Function LuaClone

engine/gui/src/gui_script.cpp:3825–3848  ·  view source on GitHub ↗

clone a node * Make a clone instance of a node. The cloned node will be identical to the * original node, except the id which is generated as the string "node" plus * a sequential unsigned integer value. * This function does not clone the supplied node's children nodes. * Use gui.clone_tree for that purpose. * * @name gui.clone * @param node [type:node] node

Source from the content-addressed store, hash-verified

3823 * @return clone [type:node] the cloned node
3824 */
3825 static int LuaClone(lua_State* L)
3826 {
3827 int top = lua_gettop(L);
3828 (void) top;
3829
3830 HNode hnode;
3831 LuaCheckNodeInternal(L, 1, &hnode);
3832
3833 Scene* scene = GuiScriptInstance_Check(L);
3834 HNode out_node;
3835 dmGui::Result result = dmGui::CloneNode(scene, hnode, &out_node);
3836 switch (result)
3837 {
3838 case dmGui::RESULT_OUT_OF_RESOURCES:
3839 return luaL_error(L, "Not enough resources to clone the node");
3840 case dmGui::RESULT_OK:
3841 MoveNodeAbove(scene, out_node, hnode);
3842 LuaPushNode(L, scene, out_node);
3843 assert(top + 1 == lua_gettop(L));
3844 return 1;
3845 default:
3846 return luaL_error(L, "An unexpected error occurred");
3847 }
3848 }
3849
3850 static int HashTableIndex(lua_State* L)
3851 {

Callers

nothing calls this directly

Calls 8

lua_gettopFunction · 0.85
LuaCheckNodeInternalFunction · 0.85
GuiScriptInstance_CheckFunction · 0.85
luaL_errorFunction · 0.85
LuaPushNodeFunction · 0.85
CloneNodeFunction · 0.70
MoveNodeAboveFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected