diff --git a/korman/nodes/node_core.py b/korman/nodes/node_core.py index 3bcca4c..c97b3b1 100644 --- a/korman/nodes/node_core.py +++ b/korman/nodes/node_core.py @@ -56,6 +56,16 @@ class PlasmaNodeBase: return i raise KeyError(key) + def find_input_sockets(self, key, idname=None): + for i in self.inputs: + if i.identifier == key: + if idname is None: + yield i + elif i.links: + node = i.links[0].from_node + if idname == node.bl_idname: + yield i + def find_output(self, key, idname=None): for i in self.outputs: if i.identifier == key: diff --git a/korman/nodes/node_responder.py b/korman/nodes/node_responder.py index b2bbb13..7daa6f2 100644 --- a/korman/nodes/node_responder.py +++ b/korman/nodes/node_responder.py @@ -41,8 +41,6 @@ class PlasmaResponderNode(PlasmaNodeVariableInput, bpy.types.Node): self.outputs.new("PlasmaRespStateSocket", "States", "states") def draw_buttons(self, context, layout): - self.ensure_sockets("PlasmaConditionSocket", "Condition", "condition") - layout.prop(self, "detect_trigger") layout.prop(self, "detect_untrigger") layout.prop(self, "no_ff_sounds") @@ -88,6 +86,9 @@ class PlasmaResponderNode(PlasmaNodeVariableInput, bpy.types.Node): stateNode.convert_state(exporter, tree, so, stateMgr) stateMgr.save() + def update(self): + self.ensure_sockets("PlasmaConditionSocket", "Condition", "condition") + class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): bl_category = "LOGIC" @@ -104,11 +105,6 @@ class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): self.outputs.new("PlasmaRespStateSocket", "Trigger", "gotostate").link_limit = 1 def draw_buttons(self, context, layout): - # This actually draws nothing, but it makes sure we have at least one empty input slot - # We need this because it's possible that multiple OTHER states can call us - self.ensure_sockets("PlasmaRespStateSocket", "Condition", "condition") - - # Now draw a prop layout.prop(self, "default_state") def convert_state(self, exporter, tree, so, stateMgr): @@ -159,6 +155,17 @@ class PlasmaResponderStateNode(PlasmaNodeVariableInput, bpy.types.Node): i.convert_command(exporter, tree, so, stateMgr.responder, commands) commands.save(state) + def update(self): + # This actually draws nothing, but it makes sure we have at least one empty input slot + # We need this because it's possible that multiple OTHER states can call us + self.ensure_sockets("PlasmaRespStateSocket", "Condition", "condition") + + # Check to see if we're the default state + if not self.default_state: + inputs = list(self.find_input_sockets("condition", "PlasmaResponderNode")) + if len(inputs) == 1: + self.default_state = True + class PlasmaRespStateSocket(PlasmaNodeSocketBase, bpy.types.NodeSocket): bl_color = (0.388, 0.78, 0.388, 1.0)