Expression

A class that stores an expression you can execute.

An expression can be made of any arithmetic operation, built-in math function call, method call of a passed instance, or built-in type construction call. An example expression text using the built-in math functions could be sqrt(pow(3,2) + pow(4,2)). In the following example we use a LineEdit node to write our expression and show the result.

More...

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

execute
Variant execute(Array inputs, GodotObject base_instance, bool show_error)

Executes the expression that was previously parsed by parse and returns the result. Before you use the returned object, you should check if the method failed by calling hasExecuteFailed. If you defined input variables in parse, you can specify their values in the inputs array, in the same order.

getErrorText
String getErrorText()

Returns the error text if parse has failed.

hasExecuteFailed
bool hasExecuteFailed()

Returns true if execute has failed.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Expression other)
opEquals
bool opEquals(typeof(null) n)
parse
GodotError parse(String expression, PoolStringArray input_names)

Parses the expression and returns an error code. You can optionally specify names of variables that may appear in the expression with input_names, so that you can bind them when it gets executed.

toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
Expression _new()

Construct a new instance of Expression. Note: use memnew!Expression instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

onready var expression = Expression.new()

func _ready(): $LineEdit.connect("text_entered", self, "_on_text_entered")

func _on_text_entered(command): var error = expression.parse(command, []) if error != OK: print(expression.get_error_text()) return var result = expression.execute([], null, true) if not expression.has_execute_failed(): $LineEdit.text = str(result)

Meta