Problem with array

Get help using Construct 2

Post » Fri Mar 23, 2012 8:32 pm

Hi all.

Thank you for your web and works.

I'm working in a little tale, and I have problems for show the texts.

First, I do
an array: Tales
and Text: TextTales

event sheet
System On start of layout:

1) Define size of Tales:
Tales = Set size to (10, 1, 0)
(10 will be the texts, for sample)

2) Define value or Tales
Tales: Set value at(1,1) to text 1"
Tales: Set value at(1,2) to text 2"
Tales: Set value at(1,3) to text 3"
...

and ending,

3) I initialize the TextTales with Tales data.

TextTales: Set text to Tales.At(1,1)

but when I execute the app,

TextTales = 0


Do you can help me, please?
suggestion?

Thank!!MarcosTrivino2012-03-23 20:34:30
B
18
S
5
Posts: 14
Reputation: 1,687

Post » Sat Mar 24, 2012 3:05 am

Hey Marcos Trivino,
Remember arrays are based off of zero. So if you are creating an array (10,1,0) then it should look like this
0,0
1,0
2,0
3,0
4,0...9,0
I put a quick example together to show you. Conversation Array

Also check out Kyatric Array examples in the array section of FAQ
Concrete commented example of use of arrays and A miniRPG example using array are great. FAQ

Hope this helpsshadowedsol2012-03-24 03:08:33
B
9
S
1
G
3
Posts: 19
Reputation: 1,628

Post » Sat Mar 24, 2012 4:02 am

A point to note from the fabulous manual:

"A simple example of a list of ten values would be a 10 x 1 x 1 array. Note that you should not set a size of 0 on any of the dimensions else the entire array becomes empty; it is correct to have a size of 1 on unused dimensions."
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Sat Mar 24, 2012 5:26 pm

Hi all,
Well, I changed the array index for your recommendation, and nothing.
Then I wrote the entire project step by step, and I havent errors. ?
(The index starts in 0,0)

I think that the problem was the drag and drop an object of other project.
I tested this idea this morning and my editor closed.
Reopened the project and the editor send me an error message.
I push ignore (or similar) button.
Delette the object
And I can continue working OK.   


The sprites, all OK.
and now I will do the buttons with background graphics.

PS.:   shadowedsol, I can't open your sample, because you use the ver 83 and I have 82. ( the downloadable free version "Construct 2 r80.2") But thanks, I was very confused trying values, and I not remembered what index starts 0.0.

PS2: Danijerry, thx for your link.

How I can open the files .cap? There are many interesting examples.


Thx for your time XDMarcosTrivino2012-03-24 17:46:52
B
18
S
5
Posts: 14
Reputation: 1,687

Post » Sat Mar 24, 2012 8:50 pm

Here is a screenshot of the array since you can't open it.


Thanks Danijerry for the correction, I forgot about that.

Cap are opened with the old Constructshadowedsol2012-03-24 21:31:21
B
9
S
1
G
3
Posts: 19
Reputation: 1,628

Post » Mon Mar 26, 2012 11:38 pm

Hi all,

I leave you this link which shows how to make a 3-state button.

I modified an example of Kyatric (thx Kyatric)

http://www.fileserve.com/file/VaeqNTM/button3states.7z

suggestions?

Bye!!
B
18
S
5
Posts: 14
Reputation: 1,687

Post » Tue Mar 27, 2012 5:48 pm

Question: do can you base an if statement off of the length of an array?
dumb question, but its early, and i happend to be reading the forum, so if its dumb and explained elsewhere i dont care :P
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Wed Mar 28, 2012 1:41 pm

Yes you can create an Event that reads multiple array values (length?) and then runs an action. Hope that is what you meant by length, but you can pretty much get anything you want out of an array.shadowedsol2012-03-28 13:50:48
B
9
S
1
G
3
Posts: 19
Reputation: 1,628


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests