Browse Source

Ensure that input sockets are available when calling

`find_input_socket()`.

It's possible that we may want to address input sockets before the
Node's `update()` method is called. In that case, we need to initialize
the socket ourselves. This is most likely to happen if you're doing
something gnawty in a Node's `init()` method.
pull/366/head
Adam Johnson 1 year ago
parent
commit
e5695178e0
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 18
      korman/nodes/node_core.py

18
korman/nodes/node_core.py

@ -110,15 +110,19 @@ class PlasmaNodeBase:
options = self._socket_defs[0].get(key, {})
spawn_empty = spawn_empty and options.get("spawn_empty", False)
for i in self.inputs:
if i.alias == key:
if spawn_empty and i.is_linked:
continue
return i
matching_sockets = filter(lambda x: x.alias == key, self.inputs)
if spawn_empty:
unused_socket = next(filter(lambda x: not x.is_linked, matching_sockets), None)
if unused_socket is not None:
return unused_socket
return self._spawn_socket(key, options, self.inputs)
else:
raise KeyError(key)
matching_socket = next(matching_sockets, None)
if matching_socket is not None:
return matching_socket
if options:
return self._spawn_socket(key, options, self.inputs)
raise KeyError(key)
def find_input_sockets(self, key, idname=None):
for i in self.inputs:

Loading…
Cancel
Save