Documentation
¶
Overview ¶
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.
package main import ( "fmt" "graphics.gd/classdb/Expression" "graphics.gd/classdb/LineEdit" ) type ExampleExpression struct { LineEdit LineEdit.Instance expression Expression.Instance } func (e *ExampleExpression) Ready() { e.expression = Expression.New() e.LineEdit.OnTextSubmitted(func(new_text string) { var err = e.expression.Parse(new_text) if err != nil { fmt.Println(e.expression.GetErrorText()) return } var result = e.expression.Execute() if !e.expression.HasExecuteFailed() { e.LineEdit.SetText(fmt.Sprint(result)) } }) }
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsExpression() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) Execute() any
- func (self Instance) GetErrorText() string
- func (self Instance) HasExecuteFailed() bool
- func (self Instance) ID() ID
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) Parse(expression string) error
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsExpression ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.Expression
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsExpression ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) Execute ¶
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.
func (Instance) GetErrorText ¶
func (Instance) HasExecuteFailed ¶
Returns true if Execute has failed.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
type MoreArgs ¶
type MoreArgs [1]gdclass.Expression
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) Execute ¶
func (self MoreArgs) Execute(inputs []any, base_instance Object.Instance, show_error bool, const_calls_only bool) any
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.