diff --git a/Sources/armory/logicnode/StringCharAtNode.hx b/Sources/armory/logicnode/StringCharAtNode.hx new file mode 100644 index 0000000000..a72ea82094 --- /dev/null +++ b/Sources/armory/logicnode/StringCharAtNode.hx @@ -0,0 +1,21 @@ +package armory.logicnode; + +class StringCharAtNode extends LogicNode { + public var char: String; + + public function new(tree:LogicTree) { + super(tree); + } + + override function run(from:Int) { + var string: String = inputs[1].get(); + var index: Int = inputs[2].get(); + char = string.charAt(index); + runOutput(0); + } + + override function get(from: Int): String { + return char; + } + +} diff --git a/blender/arm/logicnode/string/LN_string_charat.py b/blender/arm/logicnode/string/LN_string_charat.py new file mode 100644 index 0000000000..839ec5265e --- /dev/null +++ b/blender/arm/logicnode/string/LN_string_charat.py @@ -0,0 +1,18 @@ +from arm.logicnode.arm_nodes import * + + +class StringCharAtNode(ArmLogicTreeNode): + """String CharAt""" + bl_idname = 'LNStringCharAtNode' + bl_label = 'String CharAt' + bl_description = 'Returns the character at position index of the String. If the index is negative or exceeds the string.length, an empty String "" is returned.' + arm_category = 'String' + arm_version = 1 + + def arm_init(self, context): + self.add_input('ArmNodeSocketAction', 'In') + self.add_input('ArmStringSocket', 'String') + self.add_input('ArmIntSocket', 'Index') + + self.add_output('ArmNodeSocketAction', 'Out') + self.add_output('ArmStringSocket', 'Char')