Browse Source

Complain about invalid links

pull/11/head
Adam Johnson 9 years ago
parent
commit
70dc620f94
  1. 6
      korman/nodes/node_core.py

6
korman/nodes/node_core.py

@ -148,6 +148,10 @@ class PlasmaNodeBase:
return (getattr(self.__class__, "input_sockets", {}), return (getattr(self.__class__, "input_sockets", {}),
getattr(self.__class__, "output_sockets", {})) getattr(self.__class__, "output_sockets", {}))
def _tattle(self, socket, link, reason):
direction = "->" if socket.is_output else "<-"
print("Removing {} {} {} {}".format(link.from_node.name, direction, link.to_node.name, reason))
def update(self): def update(self):
"""Ensures that sockets are linked appropriately and there are enough inputs""" """Ensures that sockets are linked appropriately and there are enough inputs"""
input_defs, output_defs = self._socket_defs input_defs, output_defs = self._socket_defs
@ -178,6 +182,7 @@ class PlasmaNodeBase:
to_from_node = link.to_node if socket.is_output else link.from_node to_from_node = link.to_node if socket.is_output else link.from_node
if to_from_node.bl_idname not in allowed_nodes: if to_from_node.bl_idname not in allowed_nodes:
try: try:
self._tattle(socket, link, "(bad node)")
self.id_data.links.remove(link) self.id_data.links.remove(link)
except RuntimeError: except RuntimeError:
# was already removed by someone else # was already removed by someone else
@ -187,6 +192,7 @@ class PlasmaNodeBase:
to_from_socket = link.to_socket if socket.is_output else link.from_socket to_from_socket = link.to_socket if socket.is_output else link.from_socket
if to_from_socket.bl_idname not in allowed_sockets: if to_from_socket.bl_idname not in allowed_sockets:
try: try:
self._tattle(socket, link, "(bad socket)")
self.id_data.links.remove(link) self.id_data.links.remove(link)
except RuntimeError: except RuntimeError:
# was already removed by someone else # was already removed by someone else

Loading…
Cancel
Save