Category:boolean

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 14: Line 14:
 
|Description=Boolean that wont trigger
 
|Description=Boolean that wont trigger
 
|Code= if false then print("This code wont be run!") end
 
|Code= if false then print("This code wont be run!") end
 +
|Output=<no output>
 +
}}
 +
 +
Inverting a boolean is often very useful.
 +
The easiest way to do that is to use the "not" operator.
 +
 +
{{Example
 +
|Description=Inverting a boolean
 +
|Code=local bool = false<br> if bool then print("Boolean is false, this code is not run!") end<br> bool = not bool if bool then print("Boolean has been inverted and is now true!") end
 
|Output=<no output>
 
|Output=<no output>
 
}}
 
}}

Revision as of 00:49, 6 February 2015

A true or false value.

Booleans are often used to represent the outcome of an argument.

LUA wiki page: http://www.lua.org/pil/3.3.html
Another useful page on how to use booleans: http://lua-users.org/wiki/OperatorsTutorial

Contents

Examples

Example

Boolean that triggers an if statement

if true then print("Value is true!") end

Output:

Value is true!


Examples

Example

Boolean that wont trigger

if false then print("This code wont be run!") end

Output:

<no output>


Inverting a boolean is often very useful. The easiest way to do that is to use the "not" operator.

Examples

Example

Inverting a boolean

local bool = false<br> if bool then print("Boolean is false, this code is not run!") end<br> bool = not bool if bool then print("Boolean has been inverted and is now true!") end

Output:

<no output>

This category currently contains no pages or media.

Personal tools
Navigation