EngineImageGetFiles: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Fix description. Add example)
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 9: Line 9:
</syntaxhighlight>
</syntaxhighlight>


{{OOP||[[IMG]]:getFiles|files}}
{{OOP||img:getFiles|files}}
===Required Arguments===
===Required Arguments===
* '''imgArchive''': The [[IMG]] file handler you want to get files from.
* '''imgArchive''': The [https://gtamods.com/wiki/IMG_archive#Version_2_-_GTA_SA IMG] file handler you want to get files from.


===Returns===
===Returns===
Returns array table with files in the [[IMG]] element if successfull, false otherwise.
Returns array table with files in the [https://gtamods.com/wiki/IMG_archive#Version_2_-_GTA_SA IMG] element if successfull, false otherwise.


==Example==
==Example==
Line 25: Line 25:
outputChatBox("'file.img' contains files:")
outputChatBox("'file.img' contains files:")
for fileId = 1, #filesInArchive do
for fileId = 1, #filesInArchive do
     outputChatBox(fileId .. ": " .. filesInArchive[i])
     outputChatBox(fileId .. ": " .. filesInArchive[fileId])
end
end
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 15:40, 15 September 2025

ADDED/UPDATED IN VERSION 1.6.0 r21695:
This function gets the list of files from an IMG container.

Syntax

table engineImageGetFiles ( img imgArchive )


OOP Syntax Help! I don't understand this!

Method: img:getFiles(...)
Variable: .files


Required Arguments

  • imgArchive: The IMG file handler you want to get files from.

Returns

Returns array table with files in the IMG element if successfull, false otherwise.

Example

You could use the following code:

local img = engineLoadIMG( "file.img" )
local filesInArchive = engineImageGetFiles( img )

outputChatBox("'file.img' contains files:")
for fileId = 1, #filesInArchive do
    outputChatBox(fileId .. ": " .. filesInArchive[fileId])
end


See Also