mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
Adds in Delay Node (#10)
So a bit behind, but this adds in the Delay Node. Co-authored-by: Eroax <eroaxe.business@gmail.com> Reviewed-on: https://codeberg.org/Eroax/Re-DotDeck/pulls/10
This commit is contained in:
parent
0716c2f4da
commit
3010ead296
2 changed files with 43 additions and 0 deletions
42
classes/deck/nodes/delay.gd
Normal file
42
classes/deck/nodes/delay.gd
Normal file
|
@ -0,0 +1,42 @@
|
|||
extends DeckNode
|
||||
|
||||
var thread : Thread
|
||||
|
||||
func _init():
|
||||
name = "Delay"
|
||||
node_type = name.to_snake_case()
|
||||
description = "A Node that passes through the input after the set time."
|
||||
|
||||
add_output_port(Deck.Types.STRING, "Value", "")
|
||||
|
||||
add_input_port(Deck.Types.NUMERIC, "Delay Time", "field")
|
||||
add_input_port(Deck.Types.NUMERIC, "Value", "field")
|
||||
|
||||
|
||||
|
||||
func _receive(to_input_port, data: DeckType, extra_data: Array = []):
|
||||
|
||||
thread = Thread.new()
|
||||
thread.start(handle_delay.bind(data))
|
||||
|
||||
|
||||
func handle_delay(data):
|
||||
|
||||
var goal_time = Time.get_ticks_msec() + (int(get_input_ports()[0].value_callback.call()) * 1000)
|
||||
|
||||
while Time.get_ticks_msec() < goal_time:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
print("Delay over")
|
||||
send(0, data)
|
||||
|
||||
|
||||
func _notification(what):
|
||||
|
||||
if what == NOTIFICATION_PREDELETE and thread != null:
|
||||
|
||||
thread.wait_to_finish()
|
||||
|
||||
|
|
@ -9,6 +9,7 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
right_disconnects = true
|
||||
show_arrange_button = false
|
||||
script = ExtResource("1_pojfs")
|
||||
|
||||
[connection signal="popup_request" from="." to="." method="_on_popup_request"]
|
||||
|
|
Loading…
Reference in a new issue