mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add a super janky generic obsws request node
This commit is contained in:
parent
85b2181622
commit
c283f35936
2 changed files with 64 additions and 5 deletions
59
classes/deck/nodes/obs_websocket_generic_request.gd
Normal file
59
classes/deck/nodes/obs_websocket_generic_request.gd
Normal file
|
@ -0,0 +1,59 @@
|
|||
extends DeckNode
|
||||
|
||||
var noobs: NoOBSWS
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
name = "OBS WS Generic Request"
|
||||
node_type = "obs_generic_request"
|
||||
description = ""
|
||||
category = "obs"
|
||||
|
||||
props_to_serialize = []
|
||||
|
||||
add_virtual_port(
|
||||
DeckType.Types.STRING,
|
||||
"Request type",
|
||||
"field"
|
||||
)
|
||||
|
||||
add_virtual_port(
|
||||
DeckType.Types.STRING,
|
||||
"Request data",
|
||||
"codeblock"
|
||||
)
|
||||
|
||||
add_output_port(
|
||||
DeckType.Types.DICTIONARY,
|
||||
"Result"
|
||||
)
|
||||
|
||||
add_virtual_port(
|
||||
DeckType.Types.BOOL,
|
||||
"Request",
|
||||
"button"
|
||||
)
|
||||
|
||||
|
||||
func _receive(on_virtual_port: int, data: Variant, extra_data: Array = []) -> void:
|
||||
if on_virtual_port != 2:
|
||||
return
|
||||
|
||||
if noobs == null:
|
||||
noobs = Connections.obs_websocket
|
||||
|
||||
print(get_virtual_ports()[1].value)
|
||||
var e: Dictionary = type_convert(get_virtual_ports()[1].value, TYPE_DICTIONARY)
|
||||
print(e)
|
||||
if typeof(e) != TYPE_DICTIONARY:
|
||||
return
|
||||
|
||||
var req := noobs.make_generic_request(
|
||||
get_virtual_ports()[0].value,
|
||||
str_to_var(get_virtual_ports()[1].value)
|
||||
)
|
||||
|
||||
await req.response_received
|
||||
|
||||
var d := req.message.get_data()
|
||||
send(0, d)
|
|
@ -12,8 +12,8 @@ func _init() -> void:
|
|||
category = "general"
|
||||
|
||||
add_input_port(
|
||||
DeckType.Types.STRING,
|
||||
"Text to print",
|
||||
DeckType.Types.ANY,
|
||||
"Data to print",
|
||||
"field"
|
||||
)
|
||||
|
||||
|
@ -36,11 +36,11 @@ func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void
|
|||
|
||||
var data_to_print
|
||||
if request_value(0) != null:
|
||||
data_to_print = request_value(0)
|
||||
data_to_print = str(request_value(0))
|
||||
elif get_input_ports()[0].value_callback.get_object() && get_input_ports()[0].value_callback.call() != "":
|
||||
data_to_print = get_input_ports()[0].value_callback.call()
|
||||
data_to_print = str(get_input_ports()[0].value_callback.call())
|
||||
else:
|
||||
data_to_print = data
|
||||
data_to_print = str(data)
|
||||
|
||||
times_activated += 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue