As Flicker correctly mentioned, I was only giving an exapmle of how you'd do something like this - of course you don't need to store the state in a variable when premade functions are availiable.
Flicker, you can also use the "!"-Operator with integer-values.