Difference between revisions of "Expression"

From Castle Wiki
(improve links in value expression list)
Line 1: Line 1:
Expressions in Castle are used for many things, including calculating health for characters, crafting procedural games and animations, and even making generative artwork. Expressions sometimes take in some values as arguments and always return a result value.
An '''Expression''' is a representation of a value that is resolved while the deck is playing. Some common uses for expressions include: Reading the value of variables, performing simple math, or creating randomness. Expressions can also be nested and combined to support more complex things, such as calculating health for characters, crafting procedural games and animations, and even making generative artwork.
 
Expressions always resolve to a numeric value.
 
Some expressions take arguments. For example, when reading the value of a [[Variable]], you need to specify which variable to read. When adding two numbers, you need to specify which two numbers (or expressions) to add. Other expressions don't take any arguments, such as the '''Time elapsed since the card started'''.
 
== Using Expressions ==
Expressions are an important component of [[Rule|Rules]] in Castle. Typically, when editing a rule, any numeric value can be an expression. To edit an expression, look for the round beaker icon to the left of a number input. Press it to open a sheet to edit that expression.


== List of Expression Types ==
== List of Expression Types ==
The following is a list of expression types in the order that they are listed when viewed in the Castle "Choose expression type" sheet
=== Values ===
=== Values ===


* The value of a [[variable]]
* The value of a [[variable]]
*A constant number
*A constant number. This is the same as not using an expression.
*The value of a behavior property


=== Choices===
=== Choices===

Revision as of 17:52, 11 May 2022

An Expression is a representation of a value that is resolved while the deck is playing. Some common uses for expressions include: Reading the value of variables, performing simple math, or creating randomness. Expressions can also be nested and combined to support more complex things, such as calculating health for characters, crafting procedural games and animations, and even making generative artwork.

Expressions always resolve to a numeric value.

Some expressions take arguments. For example, when reading the value of a Variable, you need to specify which variable to read. When adding two numbers, you need to specify which two numbers (or expressions) to add. Other expressions don't take any arguments, such as the Time elapsed since the card started.

Using Expressions

Expressions are an important component of Rules in Castle. Typically, when editing a rule, any numeric value can be an expression. To edit an expression, look for the round beaker icon to the left of a number input. Press it to open a sheet to edit that expression.

List of Expression Types

Values

  • The value of a variable
  • A constant number. This is the same as not using an expression.
  • The value of a behavior property

Choices

Randomness

Spacial relationships

Arithmetic

Clock

Functions