Set a resource * Sets the resource data for a specific resource * * @name resource.set * * @param path [type:string|hash] The path to the resource * @param buffer [type:buffer] The buffer of precreated data, suitable for the intended resource type * * @examples * * Assuming the folder "/res" is added to the project custom resources: * * ```lua * -- load a texture resource and set it o
| 341 | * ``` |
| 342 | */ |
| 343 | static int Set(lua_State* L) |
| 344 | { |
| 345 | int top = lua_gettop(L); |
| 346 | |
| 347 | dmhash_t path_hash = dmScript::CheckHashOrString(L, 1); |
| 348 | dmScript::LuaHBuffer* buffer = dmScript::CheckBuffer(L, 2); |
| 349 | |
| 350 | uint32_t datasize = 0; |
| 351 | void* data = 0; |
| 352 | dmBuffer::GetBytes(buffer->m_Buffer, &data, &datasize); |
| 353 | |
| 354 | dmResource::Result r = dmResource::SetResource(g_ResourceModule.m_Factory, path_hash, data, datasize); |
| 355 | if( r != dmResource::RESULT_OK ) |
| 356 | { |
| 357 | assert(top == lua_gettop(L)); |
| 358 | return ReportPathError(L, r, path_hash); |
| 359 | } |
| 360 | assert(top == lua_gettop(L)); |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | /*# load a resource |
| 365 | * Loads the resource data for a specific resource. |
no test coverage detected