We'll probably also need some additional properties for the identifier:
$pic(filename).cache - returns a BOOL value of 1 (true) or 0 (false) indicating whether the file is in the cache or not.$pic(filename).cachesize - returns a INT or FLOAT value representing the amount of cache space occupied by the specified file.
Currently, every time the script is run, before the animation starts to loop, the command is executed
/drawpic -cp, which is not needed for files that are in the cache.
This can be avoided by adding a condition to the code that checks whether the file is in the cache, to prevent lag/pause due to unnecessary re-caching.
Example:
if (!$pic(filename).cache) { drawpic -cp @IMG 0 0 $qt(filename) }