Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/you-win/advanced-expression-gd
More powerful Expressions for Godot
https://github.com/you-win/advanced-expression-gd
godot
Last synced: 3 days ago
JSON representation
More powerful Expressions for Godot
- Host: GitHub
- URL: https://github.com/you-win/advanced-expression-gd
- Owner: you-win
- License: apache-2.0
- Created: 2022-03-30T21:22:52.000Z (almost 3 years ago)
- Default Branch: senpai
- Last Pushed: 2022-08-23T02:16:51.000Z (over 2 years ago)
- Last Synced: 2025-02-10T00:32:29.061Z (4 days ago)
- Topics: godot
- Language: GDScript
- Homepage:
- Size: 742 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advanced Expression GD
[![Chat on Discord](https://img.shields.io/discord/853476898071117865?label=chat&logo=discord)](https://discord.gg/6mcdWWBkrr)
[![package](https://img.shields.io/badge/package-1.0.0-blue)](https://www.npmjs.com/package/@sometimes_youwin/advanced-expression)Functions like Godot's built-in `Expression` class with the flexability of an actual script.
See the `tests/` directory for more examples.
## Example
```GDScript
var ae = preload("res://addons/advanced-expression/advanced_expression.gd")# Add variables
# Currently, variables must be preinitialized with a value since,
# in the author's opinion, variables should avoid being null when possible
ae.add_variable("counter").add(0)# Add function with a parameter
ae.add_function("increment") \
.add_param("input: int") \
.add("return input + 1")# Add runner code that will be run on execute
# Follows the same semantics as regular functions
ae.add() \
.add_param("starting_value") \
.add("counter = starting_value") \
.add("for i in 5:") \
.tab() \
.add("counter = increment(counter)") \
.add("return counter")# Everything must be compiled before executing
if ae.compile() != OK:
push_error("Failed to compile")# Parameters must be passed as an array
# These are passed to the runner function
assert(ae.execute([1]) == 6)
```