| 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 | { |
no test coverage detected