What is the function of this symbol "!"

basicly i have a piece of code and i need to extract the components required to compile a script that basicly uses the same method but does something differently.

that is not important but what is important is that i understand what the functions of the code do so that i know what i’m doing.

please no “if you want to learn coding then go to the scripting refs (have the t-shirt) and dont rip on other peoples work” comments… I’m not ripping on other peoples work i’m creating my own and learning how to do so by examining how others do so. got it? :stuck_out_tongue:

ok so what i dont understand is the use of the symbol “!” and the line i’m looking at is someting like this

if(!lazy  Input.GetButtonDown ("a")

i’ve also seen this used on lines like

if (!jumping)

and used with an equals symbol like

!=

now i’ve tried the scripting refs and they seem to have no info on the use of this symbol. or i just looked in the wrong place
I once read something that describes the use of this but only in passing and it was allongside many other symbols so it is a fuzzy memory to say the least
i simply cannot find out what this means
I get the feeling in meens “compared to” but i some how doubt it.
can anybody help?

Ps. Come to think of it i’m kinda unsure of the exact use of the “” symbol too.

Edit: On further examination it appears to mean the same as if (lazy = false) can anybody confirm this to me?

! simply inverses the boolean next to it, so yes, !lazy is equal to lazey == false.

! is also called “NOT” in algorithm,
as || is called “OR”,
and is called “AND”.

== means equal, != means not equal (the inverse).

thank you very much this helps loads it means i can also clean up my other code :twisted: so does that mean i can say check a series of variables like?

if(lazy || grumpy || dopey || sleepy  snowWhite)
{
//then get back to work
}

Yes, but be cautious, I don’t remember how the order of reading is…

For exemple, NeedWater || NeedFood HaveFoodInFridge.

Whether I want to drink or eat, if I have food, well I will drink/eat.

If you read the above from the left :

Do I need water or food ? If at least both are true, do I have food in my fridge ?

Read from the right :

Do I need food and do I have food in fridge ? If both are true, do I need water ?

Another solution would be to use ( ), tests are executed in them first, but it would increase the size of the code.

Thank you this is a decent opportunity for me to run some experiments on the matter :slight_smile: