We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have random texte that appears but I would like each sentence (string) to appear only one time each, during the running of the sketch. Also to go to the line I use \n is there any way to constrain my string to do it alone ? Thanks you very much !
Answers
Can you post the code you have so far? It will be useful to see your approach.
Do you have your strings stored in an array?
This next post does not answer your question but it shows one possible idea: https://forum.processing.org/two/discussion/comment/90020/#Comment_90020
Kf
@alicessing --
If you put your strings in a StringList then you can use remove to take out each randomly chosen string after it is used.
Thanks ! I am going to look at your suggestion. I have something like 100 sentences I don't think I can do it by using String list or I will have to create an inventory.append("") for each of my sentences ? Here is my code :
instead of \n look at text () with 5 parameters which is text in a box so to speak
You could shuffle the list and then bring in a counter that just goes through it with a simple ++
@alicessing --
Edit: You can create a new StringList directly from a String[] array (see GoToLoops answer below).
You can also load strings from an array into an existing StringList with an enhanced
for
loop:...taking the form:
Like this:
Once you have a StringList it can be shuffled using its shuffle() method:
...like this:
Output:
For very long lists of strings, consider saving them in a text file and loading them using loadStrings:
...like this:
your big problem is drawing everything in the same iteration of draw().
the screen is only updated at the end of each call to draw().
https://forum.processing.org/two/discussion/8085/i-display-images-in-sequence-but-i-see-only-the-last-one-why
There is also the split and splitTokens functions. If you write your phrases and they are separated by a special character (for example... your phrases enclosed in quote remarks) then you can use split like this:
The main difference is that split will produce empty Strings between contiguous delimiters while splitTokens doesn't. It treats contiguous delimiters together
Kf
Thanks very much everybody and thanks for your explanations this is not exactly what I wanted to do but finaly I think it is a better thing like this and it going to be easier for me for what I want to do then. And I will keep to try to do the other things by myself :)