Another approach might be simpler.
Remember you can store and retrieve strings using the tv_WriteUserString and tv_ReadUserString commands in the current config file between re-running the same scripts or passing info between different scripts and even saving info between TVPaint sessions (since the config file is saved to disk when you quit and reloaded when you start TVPaint again). This is very useful.
Also remember that the tv_GetAPen command really only returns a string... so why parse it in to separate variables then reconcat it into a string again? Just store the string and read it when you want to restore APen back to the original color...
Like this:
Code: Select all
tv_GetAPen
tv_WriteUserString "ColorStore" "Color1" result
tv_SetAPen 0 0 0
tv_warn "APen is now black"
tv_ReadUserString "ColorStore" "Color1"
tv_SetAPen result
All we are doing here is creating our own custom SECTION called
ColorStore and a custom LINE in that section called
Color1 in the current config file. If we want, we can extend the number of stored colors by adding new LINES to the
ColorStore section: Color2, Color3, Color4 etc. Very useful and economical. Oh, and we can name other custom SECTIONS with their own LINES to store and retrieve ANY STRINGS WE WANT in other scripts for other purposes!
Sven
p.s. If you want to test if two or more things are ALL true you can use the logic symbol && (and)... like
Code: Select all
IF CMP(r,"0") && CMP(g,"0") && CMP(b,"0")
blah blah
ELSE
not blah blah
END
Likewise, if you want to test if EITHER one OR another thing is true you can use || (or).