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

Function Script_GetId

engine/gameobject/src/gameobject/gameobject_script.cpp:1475–1488  ·  view source on GitHub ↗

gets the id of an instance * Returns or constructs an instance identifier. The instance id is a hash * of the absolute path to the instance. * * - If `path` is specified, it can either be absolute or relative to the instance of the calling script. * - If `path` is not specified, the id of the game object instance the script is attached to will be returned. * * @n

Source from the content-addressed store, hash-verified

1473 * ```
1474 */
1475 int Script_GetId(lua_State* L)
1476 {
1477 ScriptInstance* i = ScriptInstance_Check(L);
1478 if (lua_gettop(L) > 0)
1479 {
1480 const char* ident = luaL_checkstring(L, 1);
1481 dmScript::PushHash(L, GetAbsoluteIdentifier(i->m_Instance, ident));
1482 }
1483 else
1484 {
1485 dmScript::PushHash(L, i->m_Instance->m_Identifier);
1486 }
1487 return 1;
1488 }
1489
1490 static lua_State* GetLuaState(ScriptInstance* instance) {
1491 return instance->m_Script->m_LuaState;

Callers

nothing calls this directly

Calls 4

ScriptInstance_CheckFunction · 0.85
lua_gettopFunction · 0.85
PushHashFunction · 0.85
GetAbsoluteIdentifierFunction · 0.85

Tested by

no test coverage detected