miggor-StreamGraph/classes/deck/nodes/obs/obs_is_source_visible.gd
Lera Elvoé 49b8a23281 add more OBS nodes, allow specifying event subscription types in OBS connection dialog (#81)
adds:
- OBS Event Received
- OBS Set Source Visible
- OBS Is Source Visible?
- OBS Set Input Settings

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/81
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
2024-02-26 11:37:57 +00:00

66 lines
1.5 KiB
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
var noobs: NoOBSWS
func _init() -> void:
name = "OBS Is Source Visible?"
node_type = name.to_snake_case()
description = "Returns true if a source is visible in OBS."
add_input_port(
DeckType.Types.STRING,
"Scene Name",
"field",
)
add_input_port(
DeckType.Types.NUMERIC,
"Source ID",
"spinbox:unbounded",
)
add_output_port(
DeckType.Types.BOOL,
"Visible",
)
func _is_source_visible(scene_name: String, source_id: float) -> Variant:
if noobs == null:
noobs = Connections.obs_websocket
var req := noobs.make_generic_request(
"GetSceneItemEnabled",
{
"scene_name": scene_name,
"scene_item_id": source_id,
}
)
await req.response_received
var data := req.message
return data.response_data.scene_item_enabled
func _receive(to_input_port: int, data: Variant) -> void:
if noobs == null:
noobs = Connections.obs_websocket
if to_input_port == 0:
var source_id = await resolve_input_port_value_async(1)
var scene_name = str(data)
send(0, await _is_source_visible(scene_name, source_id))
else:
var scene_name = await resolve_input_port_value_async(0)
var source_id = data
send(0, await _is_source_visible(scene_name, source_id))
func _value_request(on_output_port: int) -> Variant:
var scene_name = await resolve_input_port_value_async(0)
var source_id = await resolve_input_port_value_async(1)
return await _is_source_visible(scene_name, source_id)