28 lines
874 B
Python
Raw Normal View History

2025-01-22 16:18:30 +01:00
from lnx.logicnode.lnx_nodes import *
class ObjectNode(LnxLogicVariableNodeMixin, LnxLogicTreeNode):
"""Stores the given object as a variable."""
bl_idname = 'LNObjectNode'
bl_label = 'Object'
lnx_version = 1
def lnx_init(self, context):
self.add_input('LnxNodeSocketObject', 'Object In')
self.add_output('LnxNodeSocketObject', 'Object Out', is_var=True)
def draw_label(self) -> str:
inp_object = self.inputs['Object In']
if inp_object.is_linked:
return super().draw_label()
obj_name = inp_object.get_default_value()
if obj_name == '':
obj_name = '_self'
return f'{super().draw_label()}: {obj_name}'
def synchronize_from_master(self, master_node: LnxLogicVariableNodeMixin):
self.inputs[0].default_value_raw = master_node.inputs[0].default_value_raw