Can't change a value of "myArray[0]" from draw();
in
Programming Questions
•
6 months ago
I'm coding a lyrics generator. I want the user to set structure of text that will be generated (for example: noun, verb, adverb...). I have String arrays (adjectives, verbs...) to load my word lists. I also have a two-dimensional array
speechParts [(an array of strings to be loaded)] [wrd (position of current word in the list)]
The problem is: I have a function in a class (called "activate") that is supposed to set speechParts[0] to "adjectives". But it doesn't work speechParts remains the same as I initialized it in setup().
Thank for your help!
Code from setup:
- speechParts[0]=verbs;
Function in my class:
- //Part of code that calls the function:
- if(keyPressed && key=='r'){
- activate("adjectives",0);
- }
- //The function
- void activate(String sp, int pos){
- if(sp=="adjectives"){
- speechParts[pos]=verbs;}
- wrd[pos]=int(random(speechParts[pos].length));
- }
1