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

Function NewScript

engine/gameobject/src/gameobject/gameobject_script.cpp:2374–2397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2372 }
2373
2374 HScript NewScript(lua_State* L, dmLuaDDF::LuaModule* lua_module)
2375 {
2376 Script* script = (Script*)lua_newuserdata(L, sizeof(Script));
2377 ResetScript(script);
2378 script->m_LuaState = L;
2379
2380 lua_pushvalue(L, -1);
2381 script->m_InstanceReference = dmScript::Ref(L, LUA_REGISTRYINDEX);
2382
2383 script->m_PropertySet.m_UserData = (uintptr_t)script;
2384 script->m_PropertySet.m_GetPropertyCallback = GetPropertyDefault;
2385 script->m_LuaModule = lua_module;
2386 luaL_getmetatable(L, SCRIPT);
2387 lua_setmetatable(L, -2);
2388
2389 if (!LoadScript(L, &lua_module->m_Source, script))
2390 {
2391 DeleteScript(script);
2392 return 0;
2393 }
2394
2395 lua_pop(L, 1);
2396 return script;
2397 }
2398
2399 bool ReloadScript(HScript script, dmLuaDDF::LuaModule* lua_module)
2400 {

Callers 2

ResScriptCreateFunction · 0.70
ResCreateGuiScriptFunction · 0.50

Calls 7

lua_newuserdataFunction · 0.85
lua_pushvalueFunction · 0.85
RefFunction · 0.85
lua_setmetatableFunction · 0.85
LoadScriptFunction · 0.85
ResetScriptFunction · 0.70
DeleteScriptFunction · 0.70

Tested by

no test coverage detected