forked from LeenkxTeam/LNXSDK
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from lnx.logicnode.lnx_nodes import *
 | |
| 
 | |
| 
 | |
| class ReadFileNode(LnxLogicTreeNode):
 | |
|     """Reads the given file and returns its content.
 | |
| 
 | |
|     @input File: the asset name of the file as used by Kha.
 | |
|     @input Use cache: if unchecked, re-read the file from disk every
 | |
|         time the node is executed. Otherwise, cache the file after the
 | |
|         first read and return the cached content.
 | |
| 
 | |
|     @output Loaded: activated after the file has been read.
 | |
|     @output Not Loaded: If the file doesn't exist the output is activated.
 | |
|     @output Content: the content of the file.
 | |
| 
 | |
|     @seeNode Write File
 | |
|     """
 | |
|     bl_idname = 'LNReadFileNode'
 | |
|     bl_label = 'Read File'
 | |
|     lnx_section = 'file'
 | |
|     lnx_version = 2
 | |
| 
 | |
|     def lnx_init(self, context):
 | |
|         self.add_input('LnxNodeSocketAction', 'In')
 | |
|         self.add_input('LnxStringSocket', 'File')
 | |
|         self.add_input('LnxBoolSocket', 'Use cache', default_value=True)
 | |
| 
 | |
|         self.add_output('LnxNodeSocketAction', 'Loaded')
 | |
|         self.add_output('LnxNodeSocketAction', 'Not loaded')
 | |
|         self.add_output('LnxStringSocket', 'Content')
 | |
| 
 | |
|     def get_replacement_node(self, node_tree: bpy.types.NodeTree):
 | |
|         if self.lnx_version not in (0, 1):
 | |
|             raise LookupError()
 | |
| 
 | |
|         return NodeReplacement.Identity(self)
 |