So i set my layout with one botton and 2 texts
tsxt1, text2 click
I create an array called names and create few name in it.
I make an event "ON CILCK" than i set "APPENT TEXT" to the text1 to check a value of an array based on index number.
Names.At(0, 0, 0)
I also try
and so on.
I am trying to make auto name generating for pc characters based on array list.
1. What's wrong with the code?
2. I need an function to retrive only one name randomly from the list, How can i do it?
And of course, Thank You!
At(index) should work, as it says in the manual, if Y and Z are not provided, then they are set to 0.
I think the problem comes from the initialization of your array. How do you fill it with names?
You need a one dimensional array of names. Personally, I would first set the size of the array to (NAMESCOUNT, 1, 1), where NAMESCOUNT is the number of names you have, then I would fill each X index with a string value.
Maybe you set the height or depth to 0 by mistake. From the manual : "If any of the dimensions are 0 the entire array is empty, so usually all the dimensions are at least 1."
Please provide a capx or a screenshot of your code at least for us to provide a more detailed answer.
Btw, you can read the manual for Array here : https://www.scirra.com/manual/108/array
Still not working.
This is the image from the problem please check
The Text object is useless for array manipulation, you only need it to display some text (like the content of your array) on screen.
Second mistake : Array elements are different from the object's instance variables. You don't need instance variables at all in the Array object.
To add an element to an array, use the array's Push action.
In your event sheet, this should look like :
You should check out a tutorial for using arrays in the tutorial section on this website, there are really good ones, or check out the usage of arrays in the manual.
Develop games in your browser. Powerful, performant & highly capable.