Skip to content

Commit

Permalink
Merge pull request #3021 from Onek8/main
Browse files Browse the repository at this point in the history
String CharAt node
  • Loading branch information
luboslenco authored Jul 8, 2024
2 parents c35ceda + b5f7b84 commit fd9fe31
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Sources/armory/logicnode/StringCharAtNode.hx
Original file line number Diff line number Diff line change
@@ -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;
}

}
18 changes: 18 additions & 0 deletions blender/arm/logicnode/string/LN_string_charat.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit fd9fe31

Please sign in to comment.