Garry's Mod Wiki

boolean

A true or false value.

Booleans are used to represent the outcome of a conditional statement. Provided below are some useful links:

Example

Demonstrates how conditional statements treat booleans.

if false then print("Value is false!") end if true then print("Value is true!") end
Output: Value is true!

Example

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

local bool = false if bool then print("Boolean is false, this code is not run!") end // Boolean is now being inverted ( false -> true ) bool = not bool if bool then print("Boolean has been inverted and is now true!") end // This also works backwards. Note how "!" can be used in place of "not" bool = !bool if bool then print("Boolean is false again, and won't be printed!") end
Output: Boolean has been inverted and is now true!

Page Links


Special Pages


Wikis

?

Render Time: 28ms

DB GetPage 2
Generate Html 2
SaveChanges (1) 9
Render Body 0
Render Sidebar 13