forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
47
leenkx/blender/lnx/logicnode/native/LN_call_haxe_static.py
Normal file
47
leenkx/blender/lnx/logicnode/native/LN_call_haxe_static.py
Normal file
@ -0,0 +1,47 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class CallHaxeStaticNode(LnxLogicTreeNode):
|
||||
"""Calls the given static Haxe function and optionally passes arguments to it.
|
||||
|
||||
**Compatibility info**: prior versions of this node didn't accept arguments and instead implicitly passed the current logic tree object as the first argument. In newer versions you need to pass that argument explicitly if the called function expects it.
|
||||
|
||||
@input Function: the full module path to the function.
|
||||
@output Result: the result of the function."""
|
||||
bl_idname = 'LNCallHaxeStaticNode'
|
||||
bl_label = 'Call Haxe Static'
|
||||
lnx_section = 'haxe'
|
||||
lnx_version = 3
|
||||
min_inputs = 2
|
||||
|
||||
def __init__(self):
|
||||
array_nodes[str(id(self))] = self
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Function')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxDynamicSocket', 'Result')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
row = layout.row(align=True)
|
||||
op = row.operator('lnx.node_add_input', text='Add Arg', icon='PLUS', emboss=True)
|
||||
op.node_index = str(id(self))
|
||||
op.socket_type = 'LnxDynamicSocket'
|
||||
op.name_format = "Arg {0}"
|
||||
op.index_name_offset = -2
|
||||
column = row.column(align=True)
|
||||
op = column.operator('lnx.node_remove_input', text='', icon='X', emboss=True)
|
||||
op.node_index = str(id(self))
|
||||
if len(self.inputs) == self.min_inputs:
|
||||
column.enabled = False
|
||||
|
||||
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
|
||||
if self.lnx_version not in (0, 2):
|
||||
raise LookupError()
|
||||
|
||||
if self.lnx_version == 1 or self.lnx_version == 2:
|
||||
return NodeReplacement(
|
||||
'LNCallHaxeStaticNode', self.lnx_version, 'LNCallHaxeStaticNode', 2,
|
||||
in_socket_mapping={0:0, 1:1}, out_socket_mapping={0:0, 1:1}
|
||||
)
|
12
leenkx/blender/lnx/logicnode/native/LN_clear_console.py
Normal file
12
leenkx/blender/lnx/logicnode/native/LN_clear_console.py
Normal file
@ -0,0 +1,12 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class PrintNode(LnxLogicTreeNode):
|
||||
"""Clears the system console."""
|
||||
bl_idname = 'LNClearConsoleNode'
|
||||
bl_label = 'Clear Console'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
@ -0,0 +1,10 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class DetectMobileBrowserNode(LnxLogicTreeNode):
|
||||
"""Determines the mobile browser or not (works only for web browsers)."""
|
||||
bl_idname = 'LNDetectMobileBrowserNode'
|
||||
bl_label = 'Detect Mobile Browser'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxBoolSocket', 'Mobile')
|
21
leenkx/blender/lnx/logicnode/native/LN_expression.py
Normal file
21
leenkx/blender/lnx/logicnode/native/LN_expression.py
Normal file
@ -0,0 +1,21 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class ExpressionNode(LnxLogicTreeNode):
|
||||
"""Evaluates a Haxe expression and returns its output.
|
||||
|
||||
@output Result: the result of the expression."""
|
||||
bl_idname = 'LNExpressionNode'
|
||||
bl_label = 'Expression'
|
||||
lnx_version = 1
|
||||
lnx_section = 'haxe'
|
||||
|
||||
property0: HaxeStringProperty('property0', name='', default='')
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxDynamicSocket', 'Result')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
113
leenkx/blender/lnx/logicnode/native/LN_get_date_time.py
Normal file
113
leenkx/blender/lnx/logicnode/native/LN_get_date_time.py
Normal file
@ -0,0 +1,113 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class GetDateTimeNode(LnxLogicTreeNode):
|
||||
"""Returns the values of the current date and time."""
|
||||
bl_idname = 'LNGetDateTimeNode'
|
||||
bl_label = 'Get Date and Time'
|
||||
lnx_section = 'Native'
|
||||
lnx_version = 1
|
||||
|
||||
@staticmethod
|
||||
def get_enum_id_value(obj, prop_name, value):
|
||||
return obj.bl_rna.properties[prop_name].enum_items[value].identifier
|
||||
|
||||
@staticmethod
|
||||
def get_count_in(type_name):
|
||||
return {
|
||||
'now': 0,
|
||||
'timestamp': 1,
|
||||
'timeZoneOffSet': 2,
|
||||
'weekday': 3,
|
||||
'day': 4,
|
||||
'month': 5,
|
||||
'year': 6,
|
||||
'hours': 7,
|
||||
'minutes': 8,
|
||||
'seconds': 9,
|
||||
'all': 10,
|
||||
'formatted': 11,
|
||||
}.get(type_name, 10)
|
||||
|
||||
def get_enum(self):
|
||||
return self.get('property0', 10)
|
||||
|
||||
def set_enum(self, value):
|
||||
# Checking the selection of each type
|
||||
select_current = self.get_enum_id_value(self, 'property0', value)
|
||||
select_prev = self.property0
|
||||
|
||||
#Check if type changed
|
||||
if select_prev != select_current:
|
||||
|
||||
for i in self.inputs:
|
||||
self.inputs.remove(i)
|
||||
for i in self.outputs:
|
||||
self.outputs.remove(i)
|
||||
|
||||
if (self.get_count_in(select_current) == 0):
|
||||
self.add_output('LnxStringSocket', 'Date')
|
||||
elif (self.get_count_in(select_current) == 10):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxIntSocket', 'Timestamp')
|
||||
self.add_output('LnxIntSocket', 'Timezone Offset')
|
||||
self.add_output('LnxIntSocket', 'Weekday')
|
||||
self.add_output('LnxIntSocket', 'Day')
|
||||
self.add_output('LnxIntSocket', 'Month')
|
||||
self.add_output('LnxIntSocket', 'Year')
|
||||
self.add_output('LnxIntSocket', 'Hours')
|
||||
self.add_output('LnxIntSocket', 'Minutes')
|
||||
self.add_output('LnxIntSocket', 'Seconds')
|
||||
elif (self.get_count_in(select_current) == 11):
|
||||
self.add_input('LnxStringSocket', 'Format', default_value="%Y/%m/%d - %H:%M:%S")
|
||||
self.add_output('LnxStringSocket', 'Date')
|
||||
else:
|
||||
self.add_output('LnxIntSocket', 'Value')
|
||||
|
||||
self['property0'] = value
|
||||
|
||||
|
||||
property0: HaxeEnumProperty(
|
||||
'property0',
|
||||
items = [('now', 'Now', 'Returns a Date representing the current local time.'),
|
||||
('timestamp', 'Timestamp', 'Returns the timestamp (in milliseconds) of this date'),
|
||||
('timeZoneOffSet', 'Timezone Offset', 'Returns the time zone difference of this Date in the current locale to UTC, in minutes'),
|
||||
('weekday', 'Weekday', 'Returns the day of the week of this Date (0-6 range, where 0 is Sunday) in the local timezone.'),
|
||||
('day', 'Day', 'Returns the day of this Date (1-31 range) in the local timezone.'),
|
||||
('month', 'Month', 'Returns the month of this Date (0-11 range) in the local timezone. Note that the month number is zero-based.'),
|
||||
('year', 'Year', 'Returns the full year of this Date (4 digits) in the local timezone.'),
|
||||
('hours', 'Hours', 'Returns the hours of this Date (0-23 range) in the local timezone.'),
|
||||
('minutes', 'Minutes', 'Returns the minutes of this Date (0-59 range) in the local timezone.'),
|
||||
('seconds', 'Seconds', 'Returns the seconds of this Date (0-59 range) in the local timezone.'),
|
||||
('all', 'All', 'Get all of the individual separated date and time properties'),
|
||||
('formatted', 'Formatted', 'Format the current system date and time')],
|
||||
name='',
|
||||
default='all',
|
||||
set=set_enum,
|
||||
get=get_enum)
|
||||
|
||||
|
||||
|
||||
|
||||
def __init__(self):
|
||||
array_nodes[str(id(self))] = self
|
||||
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxIntSocket', 'Timestamp')
|
||||
self.add_output('LnxIntSocket', 'Timezone Offset')
|
||||
self.add_output('LnxIntSocket', 'Weekday')
|
||||
self.add_output('LnxIntSocket', 'Day')
|
||||
self.add_output('LnxIntSocket', 'Month')
|
||||
self.add_output('LnxIntSocket', 'Year')
|
||||
self.add_output('LnxIntSocket', 'Hours')
|
||||
self.add_output('LnxIntSocket', 'Minutes')
|
||||
self.add_output('LnxIntSocket', 'Seconds')
|
||||
|
||||
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
||||
|
16
leenkx/blender/lnx/logicnode/native/LN_get_haxe_property.py
Normal file
16
leenkx/blender/lnx/logicnode/native/LN_get_haxe_property.py
Normal file
@ -0,0 +1,16 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class GetHaxePropertyNode(LnxLogicTreeNode):
|
||||
"""Returns a property of an Haxe object (via the Reflection API).
|
||||
|
||||
@seeNode Set Haxe Property"""
|
||||
bl_idname = 'LNGetHaxePropertyNode'
|
||||
bl_label = 'Get Haxe Property'
|
||||
lnx_version = 1
|
||||
lnx_section = 'haxe'
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxDynamicSocket', 'Dynamic')
|
||||
self.add_input('LnxStringSocket', 'Property')
|
||||
|
||||
self.add_output('LnxDynamicSocket', 'Value')
|
@ -0,0 +1,11 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class GetSystemLanguage(LnxLogicTreeNode):
|
||||
"""Returns the language of the current system."""
|
||||
bl_idname = 'LNGetSystemLanguage'
|
||||
bl_label = 'Get System Language'
|
||||
lnx_section = 'Native'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxStringSocket', 'Language')
|
17
leenkx/blender/lnx/logicnode/native/LN_get_system_name.py
Normal file
17
leenkx/blender/lnx/logicnode/native/LN_get_system_name.py
Normal file
@ -0,0 +1,17 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
# Class GetSystemName
|
||||
class GetSystemName(LnxLogicTreeNode):
|
||||
"""Returns the name of the current system."""
|
||||
bl_idname = 'LNGetSystemName'
|
||||
bl_label = 'Get System Name'
|
||||
lnx_section = 'Native'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxStringSocket', 'System Name')
|
||||
self.add_output('LnxBoolSocket', 'Windows')
|
||||
self.add_output('LnxBoolSocket', 'Linux')
|
||||
self.add_output('LnxBoolSocket', 'Mac')
|
||||
self.add_output('LnxBoolSocket', 'HTML5')
|
||||
self.add_output('LnxBoolSocket', 'Android')
|
11
leenkx/blender/lnx/logicnode/native/LN_loadUrl.py
Normal file
11
leenkx/blender/lnx/logicnode/native/LN_loadUrl.py
Normal file
@ -0,0 +1,11 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class LoadUrlNode(LnxLogicTreeNode):
|
||||
"""Load the given URL in a new tab (works only for web browsers)."""
|
||||
bl_idname = 'LNLoadUrlNode'
|
||||
bl_label = 'Load URL'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'URL')
|
13
leenkx/blender/lnx/logicnode/native/LN_print.py
Normal file
13
leenkx/blender/lnx/logicnode/native/LN_print.py
Normal file
@ -0,0 +1,13 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class PrintNode(LnxLogicTreeNode):
|
||||
"""Print the given value to the console."""
|
||||
bl_idname = 'LNPrintNode'
|
||||
bl_label = 'Print'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'String')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
36
leenkx/blender/lnx/logicnode/native/LN_read_file.py
Normal file
36
leenkx/blender/lnx/logicnode/native/LN_read_file.py
Normal file
@ -0,0 +1,36 @@
|
||||
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)
|
36
leenkx/blender/lnx/logicnode/native/LN_read_json.py
Normal file
36
leenkx/blender/lnx/logicnode/native/LN_read_json.py
Normal file
@ -0,0 +1,36 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class ReadJsonNode(LnxLogicTreeNode):
|
||||
"""Reads the given JSON 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 Dynamic: the content of the file.
|
||||
|
||||
@seeNode Write JSON
|
||||
"""
|
||||
bl_idname = 'LNReadJsonNode'
|
||||
bl_label = 'Read 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('LnxBoolSocket', 'Use cache', default_value=1)
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Loaded')
|
||||
self.add_output('LnxNodeSocketAction', 'Not loaded')
|
||||
self.add_output('LnxDynamicSocket', 'Dynamic')
|
||||
|
||||
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
|
||||
if self.lnx_version not in (0, 1):
|
||||
raise LookupError()
|
||||
|
||||
return NodeReplacement.Identity(self)
|
22
leenkx/blender/lnx/logicnode/native/LN_read_storage.py
Normal file
22
leenkx/blender/lnx/logicnode/native/LN_read_storage.py
Normal file
@ -0,0 +1,22 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class ReadStorageNode(LnxLogicTreeNode):
|
||||
"""Reads a value from the application's default storage file. Each
|
||||
value is uniquely identified by a key.
|
||||
|
||||
For a detailed explanation of the storage system, please read the
|
||||
documentation for the [`Write Storage`](#write-storage) node.
|
||||
|
||||
@seeNode Write Storage
|
||||
"""
|
||||
bl_idname = 'LNReadStorageNode'
|
||||
bl_label = 'Read Storage'
|
||||
lnx_section = 'file'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxStringSocket', 'Key')
|
||||
self.add_input('LnxStringSocket', 'Default')
|
||||
|
||||
self.add_output('LnxDynamicSocket', 'Value')
|
28
leenkx/blender/lnx/logicnode/native/LN_script.py
Normal file
28
leenkx/blender/lnx/logicnode/native/LN_script.py
Normal file
@ -0,0 +1,28 @@
|
||||
import bpy
|
||||
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class ScriptNode(LnxLogicTreeNode):
|
||||
"""Executes the given script."""
|
||||
bl_idname = 'LNScriptNode'
|
||||
bl_label = 'Script'
|
||||
lnx_section = 'haxe'
|
||||
lnx_version = 1
|
||||
|
||||
@property
|
||||
def property0(self):
|
||||
return bpy.data.texts[self.property0_].as_string() if self.property0_ in bpy.data.texts else ''
|
||||
|
||||
|
||||
property0_: HaxeStringProperty('property0', name='Text', default='')
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxNodeSocketArray', 'Array')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
self.add_output('LnxDynamicSocket', 'Result')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop_search(self, 'property0_', bpy.data, 'texts', icon='NONE', text='')
|
18
leenkx/blender/lnx/logicnode/native/LN_set_haxe_property.py
Normal file
18
leenkx/blender/lnx/logicnode/native/LN_set_haxe_property.py
Normal file
@ -0,0 +1,18 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class SetHaxePropertyNode(LnxLogicTreeNode):
|
||||
"""Sets a property of an Haxe object (via the Reflection API).
|
||||
|
||||
@seeNode Get Haxe Property"""
|
||||
bl_idname = 'LNSetHaxePropertyNode'
|
||||
bl_label = 'Set Haxe Property'
|
||||
lnx_section = 'haxe'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxDynamicSocket', 'Dynamic')
|
||||
self.add_input('LnxStringSocket', 'Property')
|
||||
self.add_input('LnxDynamicSocket', 'Value')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
17
leenkx/blender/lnx/logicnode/native/LN_set_vibrate.py
Normal file
17
leenkx/blender/lnx/logicnode/native/LN_set_vibrate.py
Normal file
@ -0,0 +1,17 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
import lnx.utils
|
||||
|
||||
class SetVibrateNode(LnxLogicTreeNode):
|
||||
"""Pulses the vibration hardware on the device for time in milliseconds, if such hardware exists."""
|
||||
bl_idname = 'LNSetVibrateNode'
|
||||
bl_label = 'Set Vibrate'
|
||||
lnx_section = 'Native'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxIntSocket', 'Milliseconds', default_value=100)
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
# Add permission for target android
|
||||
lnx.utils.add_permission_target_android(lnx.utils.PermissionName.VIBRATE)
|
12
leenkx/blender/lnx/logicnode/native/LN_shutdown.py
Normal file
12
leenkx/blender/lnx/logicnode/native/LN_shutdown.py
Normal file
@ -0,0 +1,12 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
class ShutdownNode(LnxLogicTreeNode):
|
||||
"""Closes the application."""
|
||||
bl_idname = 'LNShutdownNode'
|
||||
bl_label = 'Shutdown'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
31
leenkx/blender/lnx/logicnode/native/LN_write_file.py
Normal file
31
leenkx/blender/lnx/logicnode/native/LN_write_file.py
Normal file
@ -0,0 +1,31 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class WriteFileNode(LnxLogicTreeNode):
|
||||
"""Writes the given string content to the given file. If the file
|
||||
already exists, the existing content of the file is overwritten.
|
||||
|
||||
> **This node is currently only implemented on Krom**
|
||||
|
||||
@input File: the name of the file, relative to `Krom.getFilesLocation()`
|
||||
@input Content: the content to write to the file.
|
||||
|
||||
@seeNode Read File
|
||||
"""
|
||||
bl_idname = 'LNWriteFileNode'
|
||||
bl_label = 'Write 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('LnxStringSocket', 'Content')
|
||||
|
||||
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)
|
33
leenkx/blender/lnx/logicnode/native/LN_write_json.py
Normal file
33
leenkx/blender/lnx/logicnode/native/LN_write_json.py
Normal file
@ -0,0 +1,33 @@
|
||||
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.
|
||||
|
||||
> **This node is currently only implemented on Krom**
|
||||
|
||||
@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)
|
37
leenkx/blender/lnx/logicnode/native/LN_write_storage.py
Normal file
37
leenkx/blender/lnx/logicnode/native/LN_write_storage.py
Normal file
@ -0,0 +1,37 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class WriteStorageNode(LnxLogicTreeNode):
|
||||
"""Writes a given value to the application's default storage file.
|
||||
Each value is uniquely identified by a key, which can be used to
|
||||
later read the value from the storage file.
|
||||
|
||||
Each key can only refer to one value, so writing a second value with
|
||||
a key that is already used overwrites the already stored value with
|
||||
the second value.
|
||||
|
||||
The location of the default storage file varies on different
|
||||
platforms, as implemented by the Kha storage API:
|
||||
- *Windows*: `%USERPROFILE%/Saved Games/<application name>/default.kha`
|
||||
- *Linux*: one of `$HOME/.<application name>/default.kha`, `$XDG_DATA_HOME/.<application name>/default.kha` or `$HOME/.local/share/default.kha`
|
||||
- *MacOS*: `~/Library/Application Support/<application name>/default.kha`
|
||||
- *iOS*: `~/Library/Application Support/<application name>/default.kha`
|
||||
- *Android*: `<internalDataPath>/<application package name>/files/default.kha`
|
||||
- *HTML 5*: saved in the local storage (web storage API) for the project's [origin](https://developer.mozilla.org/en-US/docs/Glossary/Origin).
|
||||
|
||||
`<application name>` refers to the name set at `Leenkx Exporter > Name`,
|
||||
`<application package name>` is the generated package name on Android.
|
||||
|
||||
@seeNode Read Storage
|
||||
"""
|
||||
bl_idname = 'LNWriteStorageNode'
|
||||
bl_label = 'Write Storage'
|
||||
lnx_section = 'file'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxStringSocket', 'Key')
|
||||
self.add_input('LnxDynamicSocket', 'Value')
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
0
leenkx/blender/lnx/logicnode/native/__init__.py
Normal file
0
leenkx/blender/lnx/logicnode/native/__init__.py
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user