mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
0716c2f4da
Adds both the Codeblock Descriptor along with the needed update to Port.set_value to allow Callbacks. + Adds the Expression node which utilizes the Codeblock descriptor. Co-authored-by: Eroax <eroaxe.business@gmail.com> Co-authored-by: Lera Elvoé <yagich@poto.cafe> Reviewed-on: https://codeberg.org/Eroax/Re-DotDeck/pulls/9
36 lines
641 B
GDScript
36 lines
641 B
GDScript
extends DeckNode
|
|
|
|
var expr = Expression.new()
|
|
|
|
func _init():
|
|
name = "Expression"
|
|
node_type = name.to_snake_case()
|
|
description = "A Node holding a block of executable GDScript code."
|
|
category = "general"
|
|
|
|
props_to_serialize = []
|
|
|
|
add_output_port(DeckType.Types.ANY, "Expression Text", "codeblock")
|
|
|
|
|
|
|
|
func _value_request(from_port : int) -> Variant:
|
|
|
|
var text = get_output_ports()[0].value_callback.call()
|
|
|
|
var err = expr.parse(text)
|
|
if err != OK:
|
|
|
|
printerr(err)
|
|
return null
|
|
|
|
|
|
var res = expr.execute()
|
|
if expr.has_execute_failed():
|
|
|
|
printerr("Expression Execution Failed: ", text)
|
|
return null
|
|
|
|
|
|
return res
|
|
|