miggor-StreamGraph/classes/deck/nodes/twitch/twitch_join_chat.gd
Eroax 2d5fcd25f6 Reworks Twitch Nodes to work with the new Triggers Workflow. (#82)
Closes #59 by reworking Twitch Nodes to use the new Trigger workflow that allows inputs that trigger through Ports with Port.UsageType.BOTH as well the functionality for Port.UsageType.VALUE_REQUEST and Port.UsageType.TRIGGER.

Co-authored-by: Eroax <eroaxebusiness@duck>
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/82
2024-02-26 11:36:19 +00:00

35 lines
803 B
GDScript

# (c) 2023-present Eroax
# (c) 2023-present Yagich
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
extends DeckNode
func _init():
name = "Twitch Join Chat"
node_type = name.to_snake_case()
description = "Joins a Twitch channel."
props_to_serialize = []
# Adds Input port for channel name
add_input_port(DeckType.Types.STRING, "Channel", "field")
# Adds Trigger for leaving the specified channel
add_input_port(DeckType.Types.ANY, "Join Channel", "button", Port.UsageType.TRIGGER)
func _receive(to_input_port, data: Variant):
var channel
if to_input_port == 0:
channel = data
if to_input_port == 1 or not channel is String:
channel = await resolve_input_port_value_async(0)
Connections.twitch.join_channel(channel)