# ChardScript Booleans

Booleans represent one of two values: `true` or `false`.

***

### Boolean Values

In programming you often need to know if an expression is `true` or `false`.

You can evaluate any expression in ChardScript, and get one of two answers, `1` or `0`, `1` is `true` and `0` is `false`.

When you compare two values, the expression is evaluated and ChardScript returns the Boolean answer:

#### Example

{% code lineNumbers="true" %}

```renpy
echo(10 > 9)
echo(10 == 9)
echo(10 < 9)
```

{% endcode %}

When you run a condition in an if statement, ChardScript returns `true` or `false`:

#### Example

Print a message based on whether the condition is `true` or `false`:

{% code lineNumbers="true" %}

```renpy
call a = 200
call b = 33

if b > a then
  echo("b is greater than a")
else
  echo("b is not greater than a")
end
```

{% endcode %}

### Functions can Return a Boolean

You can create functions that returns a Boolean Value:

#### Example

Print the answer of a function:

{% code lineNumbers="true" %}

```renpy
group myFunction()
  give true
end

echo(myFunction())
```

{% endcode %}

You can execute code based on the Boolean answer of a function:

#### Example

Print "YES!" if the function returns true, otherwise print "NO!":

{% code lineNumbers="true" %}

```renpy
group myFunction()
  give true

if myFunction() then
  print("YES!")
else
  print("NO!")
end
```

{% endcode %}

ChardScript also has many built-in functions that return a boolean value, like`isnumber()`, `isstring()`,`islist()`and`isgroup()`functions.

#### Example

Check if an object is an number or not:

{% code lineNumbers="true" %}

```renpy
call x = 200
echo(isnumber(x))
```

{% endcode %}

#### Example

Check if an object is an string or not:

{% code lineNumbers="true" %}

```renpy
call x = "Hello World!"
echo(isstring(x))
```

{% endcode %}

#### Example

Check if an object is an list or not:

{% code lineNumbers="true" %}

```renpy
call x = ["apple", "banana"]
echo(islist(x))
```

{% endcode %}

#### Example

Check if an object is an function or not:

{% code lineNumbers="true" %}

```renpy
group my_function()
  give "Return from a function"
end

echo(isgroup(x))
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gamingmod.gitbook.io/chardscript-docs/chardscript-tutorial/chardscript-booleans.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
