forked from LeenkxTeam/LNXSDK
		
	
		
			
	
	
		
			32 lines
		
	
	
		
			1017 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			32 lines
		
	
	
		
			1017 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								from lnx.logicnode.lnx_nodes import *
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class WriteJsonNode(LnxLogicTreeNode):
							 | 
						||
| 
								 | 
							
								    """Writes the given content to the given JSON file. If the file
							 | 
						||
| 
								 | 
							
								    already exists, the existing content of the file is overwritten.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @input File: the name of the file, relative to `Krom.getFilesLocation()`,
							 | 
						||
| 
								 | 
							
								        including the file extension.
							 | 
						||
| 
								 | 
							
								    @input Dynamic: the content to write to the file. Can be any type that can
							 | 
						||
| 
								 | 
							
								        be serialized to JSON.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @seeNode Read JSON
							 | 
						||
| 
								 | 
							
								    """
							 | 
						||
| 
								 | 
							
								    bl_idname = 'LNWriteJsonNode'
							 | 
						||
| 
								 | 
							
								    bl_label = 'Write JSON'
							 | 
						||
| 
								 | 
							
								    lnx_section = 'file'
							 | 
						||
| 
								 | 
							
								    lnx_version = 2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def lnx_init(self, context):
							 | 
						||
| 
								 | 
							
								        self.add_input('LnxNodeSocketAction', 'In')
							 | 
						||
| 
								 | 
							
								        self.add_input('LnxStringSocket', 'File')
							 | 
						||
| 
								 | 
							
								        self.add_input('LnxDynamicSocket', 'Dynamic')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        self.add_output('LnxNodeSocketAction', 'Out')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def get_replacement_node(self, node_tree: bpy.types.NodeTree):
							 | 
						||
| 
								 | 
							
								        if self.lnx_version not in (0, 1):
							 | 
						||
| 
								 | 
							
								            raise LookupError()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return NodeReplacement.Identity(self)
							 |