simple george question

A forum dedicated to George scripting questions
Post Reply
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

simple george question

Post by Lukas »

I've not programmed much in my life, so this is probably a newbie question :)

What's the best way to check if multiple things are true?

For example if I want to check if colour A is black... Can I somehow do something like this:

Code: Select all

tv_GetAPen
PARSE result R G B A
IF CMP("R G B", "0 0 0")
#PRINT yes its black
ELSE
#print no its not black
END
I know IF CMP("R G B", "0 0 0") doesn't work, but what am I doing wrong? Is it possible at all?

Right now I fix these things something like this:

Code: Select all

tv_GetAPen
PARSE result R G B A
IF CMP(R, 0)
IF CMP(G, 0)
IF CMP(B, 0)
#PRINT yes its black
END
END
END
...But it's ugly and can probably be done easier.
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: simple george question

Post by Mads Juul »

you should not include your varables in " then it becomes a string instead of the value of variables, more like this:


CMP(R" "G" "B,"0 0 0")
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: simple george question

Post by Lukas »

madsjuul wrote:you should not include your varables in " then it becomes a string instead of the value of variables, more like this:


CMP(R" "G" "B,"0 0 0")
Thanks!

Now I can store the old A color in B for all brushes that need to change color so can always go back with an invert A/B shortcut. :)

Code: Select all

R = 0
G = 0
B = 0
// New color

tv_GetAPen
PARSE result Ra Ga Ba Aa
tv_GetBPen
PARSE result Rb Gb Bb Ab
// Old colors

IF CMP(R" "G" "B, Ra" "Ga" "Ba)
// A is already good
ELSE

IF CMP(Rb" "Gb" "Bb, R" "G" "B)
tv_SetAPen Rb" "Gb" "Bb // make A like B was
tv_SetBPen Ra" "Ga" "Ba // make B like A was

ELSE
tv_SetBPen Ra" "Ga" "Ba // make B like A was
tv_SetAPen R" "G" "B // make A new color
END

END


BUT I don't understand why this works though..

Code: Select all

R" "G" "B
Are the spaces between " marks? why?
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
User avatar
ematecki
Site Admin
Posts: 2258
Joined: 15 Feb 2006, 14:32

Re: simple george question

Post by ematecki »

Putting several strings one behind the other concatenates them.

So A" "B" "C means : concatenate the (string) value of A with the literal string <one space> with the (string) value of B with the literal string <one space> with the (string) value of C.

There is no special "concatenate" operator for strings in george, just put them one behind the other.
Quicktime is DEAD. Get over it and move on !
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: simple george question

Post by Lukas »

Ok, that's very clear! :) Thanks
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
Svengali
Posts: 1557
Joined: 28 Dec 2006, 10:08

Re: simple george question

Post by Svengali »

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).
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
User avatar
Lukas
Posts: 526
Joined: 14 Jan 2011, 11:15
Contact:

Re: simple george question

Post by Lukas »

Thanks for the quick lesson Svengali! :) I'll definitely try it out.
  • Lukas Sketch Panel
  • TVPaint Pro 11.7.3
  • MacBook Pro 2018 macOS Ventura 13.4.1 + PC Windows 10
  • Wacom Cintiq 27QHD + Wacom Intuos4
  • YouTube.com/@ClubBaboo
  • YouTube.com/@FrameOrder
Post Reply