-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3021 from Onek8/main
String CharAt node
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |