Pulling Object Variables into Arrays

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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:

    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:

    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:

    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.


  • 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)


    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,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 )

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


  • 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.

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

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

    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.


  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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...


Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)