Pulling Object Variables into Arrays

Discussion and feedback on Construct 2

Post » Mon Jul 06, 2015 4:04 pm

Hey all.

I'm sure I'm not going about this the right way, and it's doing my head in,. Thus I'm turning to you, my clever fellow constructers!

Here's the situation: I'm building a quest system for the game I'm working on. I'd like objects to hold the quest info in their instance variables. On pickup, I want to transfer that data into an array.

Here's how the object part looks:

Image

Here's where things are going pear-shaped.

No matter how I change the method, I can't get this info into the array. I can store it in other variables, but the array part is just not working. Any help? Here's the 'pulling' part:

Image

The disabled ones are other versions of the same thing I tried ... no dice.

Finally, here's the loop which sets the text when the quest ui is open:

Image

It's mainly the middle part. If I could just get the info into the array I'd be good, but for some reason it's just not working. Hjalp?

Ideally I'd like the array to store all the info in rows. Eg: X0=Quest Number, Y0=Quest Name, and then access that later. (Please don't point me to the manual btw, I've read it until my head hurts)! X)

Thank you kindly.

Jimzip :D
Last edited by Jimzip on Tue Jul 07, 2015 1:27 pm, edited 1 time in total.
B
6
S
1
Posts: 28
Reputation: 465

Post » Mon Jul 06, 2015 4:18 pm

When stuffing things in arrays I always use:

width: 0
height 7 (1 for each value you want to store associated with the entry, number derived from your example object)
depth:0

in one action:
Push front on X axis: object.dialogueparts
Set X,Y value : 0 , 1 , object.itemtype
set X,Y value: 0 , 2 , Dialogue1
set X,Y value: 0 , 3 Dialogue2
etc etc


The push front, pushes all other X axis up one on the Xaxis and adds one to the width of the array.
Then the item inserted will be at 0,0 (object.dialogueparts)
Seeing as we are still at the front of the array with the item we are adding, we simply refer to X 0
0,1
0,2
0,3
0,4 etc etc

Where all the second value represent the Y, which are the items belonging to the entry.


Now, you can reference these entries with Arrayname.At(0,2) (this would get you the dialogue2 )
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Tue Jul 07, 2015 1:29 pm

Thanks a heap for the explanation lennaert! I'll try this out. :)

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465

Post » Tue Jul 07, 2015 2:25 pm

So I tried the above solution, but I still get nothing in the array. :(

There must be another problem, because the logic here seems fine. I just can't figure out what that problem is! Driving me crazy, I'm sure it's something simple.

Here's the current way I'm doing it. Like you suggested, first I'm pushing the info into the array.

Image

Then I find it and change the text to the quest description (which should be at 0,1).

Image

But ... there's nothing in the array.

Image

Any ideas?? It's ridiculous. The global test variables I made get the data just fine. The array just doesn't want to play along though.

The weird thing is, it registers *something*. The space is created, but I get the 3 commas ',,,' instead of the data.

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465

Post » Tue Jul 07, 2015 3:07 pm

Hmm, the odd thing is that you have 2 entries where you appear to be making just 1.

Perhaps there is something else happening in your events.

If you can post a capx or pm me one, I wouldn't mind taking a look.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Tue Jul 07, 2015 3:34 pm

The unused dimension(depth) has to be 1
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Tue Jul 07, 2015 7:36 pm

Thank you guys! StormHo you're right, and lannaert using your method it now works. :) I still have much to learn about arrays. I just set the depth to 1 and it functions. Now to figure out that duplicate entry...

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465


Return to Construct 2 General

Who is online

Users browsing this forum: Artpunk and 4 guests