release a resource * Release a resource. * * [icon:attention] This is a potentially dangerous operation, releasing resources currently being used can cause unexpected behaviour. * * @name resource.release * * @param path [type:hash|string] The path to the resource. * */
| 1240 | * |
| 1241 | */ |
| 1242 | static int ReleaseResource(lua_State* L) |
| 1243 | { |
| 1244 | DM_LUA_STACK_CHECK(L, 0); |
| 1245 | dmhash_t path_hash = dmScript::CheckHashOrString(L, 1); |
| 1246 | HResourceDescriptor rd = dmResource::FindByHash(g_ResourceModule.m_Factory, path_hash); |
| 1247 | if (!rd) { |
| 1248 | return luaL_error(L, "Could not release resource: %s", dmHashReverseSafe64(path_hash)); |
| 1249 | } |
| 1250 | dmGameObject::HInstance sender_instance = dmScript::CheckGOInstance(L); |
| 1251 | dmGameObject::HCollection collection = dmGameObject::GetCollection(sender_instance); |
| 1252 | dmGameObject::RemoveDynamicResourceHash(collection, path_hash); |
| 1253 | dmResource::Release(g_ResourceModule.m_Factory, dmResource::GetResource(rd)); |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | /*# set a texture |
| 1258 | * Sets the pixel data for a specific texture. |
nothing calls this directly
no test coverage detected