|
| 05 Feb 2013 01:36 AM |
## Note ##
"if" statements fire when the condition is true. Example:
local bool=true if bool then -- This will fire because bool is true
## Explanation ##
The "not" operator is used to contrast a true/false variable.
Example:
if not false then -- This would fire because it contrasts false to true because false is the opposite of true.
That is the same as:
if true then -- This would fire because true is true.
Understand? Ok.
"not" can also be used in other situations to shorten your code.
Example:
script.Parent.MouseButton1Down:connect(function() if script.Parent.Parent.Frame.Visible then script.Parent.Parent.Frame.Visible=false else script.Parent.Parent.Frame.Visible=true end end)
That is a simple open/close GUI script. Nevermind the parenting and stuff, I just made that up. Using the "not" statement you can shorten that to 3 lines.
script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Frame.Visible=not script.Parent.Parent.Frame.Visible end)
See what I did there? I simply changed the Visibility of "Frame" to the opposite of what it was using "not".
## Other examples ##
print(not true) --> false print(not false) --> true print(not not false) --> false print(not not true) --> true print(not not not not not false) --> true
I hoped this helped for some of you. (And sorry for any grammar/english mistakes. English is my second language)
-- i liek pineapples. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
| |
|
| |
|
|
| 05 Feb 2013 02:16 AM |
eh, just felt like writing it.
-- i liek pineapples. |
|
|
| Report Abuse |
|
|
thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
| |
|
|
| 05 Feb 2013 03:56 AM |
too bad.
-- i liek pineapples. |
|
|
| Report Abuse |
|
|
thane1326
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 867 |
|
| |
|