- If not found it fails ungracefully aborting any running macro
- If 2 tokens share the same name, it fails ungracefully aborting any running macro
- It does not work on IDs
In onCampaignLoad define the new getImage function (which replaces the old!):
Code: Select all
[H: defineFunction("getImage", "udfGetImage@LIBRARYTOKENNAME",1,1)]
udfGetImage
Code: Select all
<!--
// Parameter count checking
// If 1 parameter treat it as a token name
// If there are more than 1 parameters, treat the first as a token ID and the second as a size parameter
// If the size parameter is 0, do not specify the size
[H: udfGetImage.acount = argCount() ]
[H, IF( udfGetImage.acount >= 1): udfGetImage.arg0 = arg(0); udfGetImage.arg0 = "" ]
[H, IF( udfGetImage.acount >= 2): udfGetImage.arg1 = arg(1); udfGetImage.arg1 = "" ]
[H: udfisID = if( udfGetImage.acount >= 2, 1, 0) ]
// Returns an empty string if image not found OR if duplicate token names exist
[H: udfGetImage.return = ""]
[ IF( ! udfisID ), CODE: {
[ udfGetImage.return = oldFunction( udfGetImage.arg0 ) ]
};{}]
[ IF( udfisID && udfGetImage.arg1 == 0), CODE: {
[ TOKEN( udfGetImage.arg0 ): udfGetImage.return = getTokenImage() ]
};{}]
[ IF( udfisID && udfGetImage.arg1 != 0), CODE: {
[ TOKEN( udfGetImage.arg0 ): udfGetImage.return = getTokenImage( udfGetImage.arg1 ) ]
};{}]
[H: macro.return = udfGetImage.return ]
-->