add string operation nodes

This commit is contained in:
BlackGoku36 2019-09-30 00:22:00 +05:30
parent a3e45a3a5e
commit a5db10437f
12 changed files with 213 additions and 0 deletions

View file

@ -0,0 +1,24 @@
package armory.logicnode;
class CaseStringNode extends LogicNode {
public var property0:String;
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var s:String = inputs[0].get();
if (s == null) return null;
switch (property0) {
case "Upper Case":
return s.toUpperCase();
case "Lower Case":
return s.toLowerCase();
}
return false;
}
}

View file

@ -0,0 +1,15 @@
package armory.logicnode;
class LengthStringNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var s:String = inputs[0].get();
if (s == null) return null;
return s.length;
}
}

View file

@ -0,0 +1,15 @@
package armory.logicnode;
class ParseFloatNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var s:String = inputs[0].get();
if (s == null) return null;
return Std.parseFloat(s);
}
}

View file

@ -0,0 +1,16 @@
package armory.logicnode;
class SplitStringNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var s1:String = inputs[0].get();
var s2:String = inputs[1].get();
if (s1 == null || s2 == null) return null;
return s1.split(s2);
}
}

View file

@ -0,0 +1,17 @@
package armory.logicnode;
class SubStringNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var string:String = inputs[0].get();
var start:Int = inputs[1].get();
var end:Int = inputs[2].get();
if (start == null || end == null || string == null) return null;
return string.substring(start, end);
}
}

View file

@ -0,0 +1,17 @@
package armory.logicnode;
class SubStringNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function get(from:Int):Dynamic {
var string:String = inputs[0].get();
var start:Int = inputs[1].get();
var end:Int = inputs[2].get();
if (start == null || end == null || string == null) return null;
return string.substring(start, end);
}
}

View file

@ -0,0 +1,24 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class CaseStringNode(Node, ArmLogicTreeNode):
'''Converts strings's case node'''
bl_idname = 'LNCaseStringNode'
bl_label = 'Case String'
bl_icon = 'CURVE_PATH'
property0: EnumProperty(
items = [('Upper Case', 'Upper Case', 'Upper Case'),
('Lower Case', 'Lower Case', 'Lower Case'),
],
name='', default='Upper Case')
def init(self, context):
self.inputs.new('NodeSocketString', 'String')
self.outputs.new('NodeSocketString', 'String')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
add_node(CaseStringNode, category='Value')

View file

@ -0,0 +1,16 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class LengthStringNode(Node, ArmLogicTreeNode):
'''String Length node'''
bl_idname = 'LNLengthStringNode'
bl_label = 'String Length'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.outputs.new('NodeSocketInt', 'length')
self.inputs.new('NodeSocketString', 'String')
add_node(LengthStringNode, category='Value')

View file

@ -0,0 +1,16 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class ParseFloatNode(Node, ArmLogicTreeNode):
'''Parse float node'''
bl_idname = 'LNParseFloatNode'
bl_label = 'Parse float'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.outputs.new('NodeSocketFloat', 'Float')
self.inputs.new('NodeSocketString', 'String')
add_node(ParseFloatNode, category='Value')

View file

@ -0,0 +1,17 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class SplitStringNode(Node, ArmLogicTreeNode):
'''Split string node'''
bl_idname = 'LNSplitStringNode'
bl_label = 'Split String'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.outputs.new('ArmNodeSocketArray', 'Array')
self.inputs.new('NodeSocketString', 'String')
self.inputs.new('NodeSocketString', 'Split')
add_node(SplitStringNode, category='Value')

View file

@ -0,0 +1,18 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class SubStrNode(Node, ArmLogicTreeNode):
'''Sub str node'''
bl_idname = 'LNSubStrNode'
bl_label = 'Sub Str'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.outputs.new('NodeSocketString', 'String')
self.inputs.new('NodeSocketString', 'String')
self.inputs.new('NodeSocketInt', 'Position')
self.inputs.new('NodeSocketInt', 'Length')
add_node(SubStrNode, category='Value')

View file

@ -0,0 +1,18 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class SubStringNode(Node, ArmLogicTreeNode):
'''Sub string node'''
bl_idname = 'LNSubStringNode'
bl_label = 'Sub String'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.outputs.new('NodeSocketString', 'String')
self.inputs.new('NodeSocketString', 'String')
self.inputs.new('NodeSocketInt', 'Start')
self.inputs.new('NodeSocketInt', 'End')
add_node(SubStringNode, category='Value')