Resource info
Jump to navigation
Jump to search
Description
meta_data = resource_info(filename)
resource_info can be used to get information of a resource file. This can also be used to check if a resource exists.
Return value
Argument | Type | Description |
---|---|---|
meta_data | Table | This object contains all the information of the queried resource. Note that this value is nil when the resource does not exist. |
Arguments
# | Argument | Type | Description |
---|---|---|---|
1 | filename | String | The file name of the resource. Including it's extension. |
Resource types
Name | Property | Type | Description |
---|---|---|---|
IMAGE | |||
TYPE | String | Always "IMAGE" | |
WIDTH | Number | The width of the image | |
HEIGHT | Number | The height of the image | |
SOUND | |||
TYPE | String | Always "SOUND" | |
JSON | From AM/AP 3.7 | ||
TYPE | String | Always "JSON" | |
CSV | From AM/AP 3.7 | ||
TYPE | String | Always "CSV" | |
TXT | From AM/AP 3.7 | ||
TYPE | String | Always "TXT" | |
UNKNOWN | From AM/AP 4.0 | ||
TYPE | String | Always "UNKNOWN" |
Example
-- We are looking for more information about the bla.png image
resource_meta = resource_info("bla.png")
-- Check if the image could be found
if resource_meta == nil then
print("bla.png not found!")
elseif resource_meta["TYPE"] == "IMAGE" then
print("bla.png is an image and has w=" .. resource_meta["WIDTH"] .. " h=" .. resource_meta["HEIGHT"])
else
print("bla.png is not an image!")
end