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

Function Script_GetParent

engine/gameobject/src/gameobject/gameobject_script.cpp:1254–1268  ·  view source on GitHub ↗

get the parent for a specific game object instance * Get the parent for a game object instance. * * @name go.get_parent * @param [id] [type:string|hash|url] optional id of the game object instance to get parent for, defaults to the instance containing the calling script * @return parent_id [type:hash|nil] parent instance or `nil` * @examples * * Get parent o

Source from the content-addressed store, hash-verified

1252 *
1253 */
1254 int Script_GetParent(lua_State* L)
1255 {
1256 Instance* instance = ResolveInstance(L, 1);
1257 Instance* parent = dmGameObject::GetParent(instance);
1258 if (parent != 0)
1259 {
1260 dmScript::PushHash(L, parent->m_Identifier);
1261 }
1262 else
1263 {
1264 lua_pushnil(L);
1265 }
1266 return 1;
1267
1268 }
1269
1270 /*# gets the game object instance world position
1271 * The function will return the world position calculated at the end of the previous frame.

Callers

nothing calls this directly

Calls 4

ResolveInstanceFunction · 0.85
GetParentFunction · 0.85
PushHashFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected