Hello. please tell me.
I got a string from a text file using the following logical node.
This string is separated by spaces or newlines.
I want to put in the array as follows
Input0 = L2
Input1 = R2
Input2 = U’
…
Thank you.
Hello. please tell me.
I got a string from a text file using the following logical node.
This string is separated by spaces or newlines.
I want to put in the array as follows
Input0 = L2
Input1 = R2
Input2 = U’
…
Thank you.
There isn’t a way to do that in nodes right now. If you write just a little Haxe and Python you could make your own node that does it though. Here is an example of a logic_node pack that you could use as a reference if you wanted to make your own node.
If you don’t want to write it yourself, you can open a feature request on GitHub for it.
… and, as various of us solve practical problems that [all of us] face, don’t forget that a “feature request” can certainly include: “and now, here (for better or for worse) is what I wrote …” Who knows, you just might become a Contributor.
Thank you for answering.
I am not good at English so I may not understand exactly what you are saying.
Are you saying that there may be no one to respond to a feature request?
I think that is a matter of course.
Nodes is not my forte, so I did a quick solution in Haxe, you may “port” it to nodes. It manually finds the substrings separated by a space with an iterator. Also take into consideration that this function expects “perfect input” (e.g. a space at the end of the string) so if you don’t add any checks, that may cause some trouble when debugging later.
// https://haxe.org/manual/lf-iterators.html
class MyStringIterator {
var s:String;
var i:Int;
public function new(s:String) {
this.s = s;
i = 0;
}
public function hasNext() {
return i < s.length;
}
public function next() {
return s.charAt(i++);
}
}
function stringDecomp(longString:String){
// longString = "ab bc cd ef gh ij kl mn op qr st uv wx yz "; example
var inputs = [];
var myIt = new MyStringIterator(longString);
var counter = 0;
var strAccum = "";
for (c in myIt)
{
if(c != " ")
strAccum += c;
else
{
// additional checks could be added here to verify that the string retrieved format is correct
inputs[counter] = strAccum;
strAccum = "";
counter++;
}
}
return inputs;
}
I was very helpful for your polite response and I studied. Thank you.
I will try to create a logic node.
No problem , feel free to ask if you have any questions about the script.