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

Function CreateScriptInstance

engine/script/src/test/test_script_timer.cpp:791–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789};
790
791static void CreateScriptInstance(lua_State* L, const char* type)
792{
793 ScriptInstance* i = (ScriptInstance *)lua_newuserdata(L, sizeof(ScriptInstance));
794 i->m_InstanceReference = dmScript::Ref( L, LUA_REGISTRYINDEX );
795
796 lua_newtable(L);
797 i->m_ContextTableReference = dmScript::Ref( L, LUA_REGISTRYINDEX );
798 i->m_UniqueScriptId = dmScript::GenerateUniqueScriptId();
799
800 lua_rawgeti(L, LUA_REGISTRYINDEX, i->m_InstanceReference);
801 luaL_getmetatable(L, type);
802 lua_setmetatable(L, -2);
803}
804
805static void DeleteScriptInstance(lua_State* L)
806{

Callers 1

TEST_FFunction · 0.85

Calls 5

lua_newuserdataFunction · 0.85
RefFunction · 0.85
GenerateUniqueScriptIdFunction · 0.85
lua_rawgetiFunction · 0.85
lua_setmetatableFunction · 0.85

Tested by

no test coverage detected