Array Editor - How do I tweak the variables?

0 favourites
  • 10 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello All,

    After running away from Arrays, I've decided to listen to the kind advice of dop2000 and give it another try. So I finally made the basic setup that handle that scary part of the Ajax and Json and all that mishmash in my brain and now it appears on the Debug so I know it works and the Array Editor is connected to the Array of my Items.

    I want to start SIMPLE so I will get the idea how things are working so I can use the Array and add items and their different conditions to the game.

    So I made this pretty empty but organized Array Editor (I will change it later and add more to it)

    And it made sense to me that I will need to use Global Variables for the Player so I can change the speed, max jump and other things later.

    So I have these global variables for now:

    P1_Jump = 360

    P1_Gravity = 1500

    P1_Speed = 100

    Item_Number = 0

    Which are my current default Platformer stats and the number of the Item so I can choose it randomly.

    I made a "Every tick" so the Platform stats will always equal to the Global Variables as above.

    The way the Item set: I made 1 Sprite with different animations, each animation represent different Item.

    I wasn't sure if I need to actually make many individual Items, so I tried this for organization sack. [/img]

    So far so good, now... As you can see on the Array Editor screenshot I attached, I don't know how to handle it yet and this is where I got lost.

    I want to do 2 things:

    1 - When the Player pickup the "RANDOMIZER" (a question mark Sprite) by overlapping and press UP

    I want the Item to change randomly to one of the Array Editor, and change the Item's Sprite Animation.

    2 - I want each Item on the editor to change the Global variables as needed.

    As you can see I'm very confused with the Array Editor, but I want to give it a chance maybe it's not scary as I think it is?

    I hope anyone can help me here, how do I make these work?

    Thanks ahead!

  • To save global variables and sort values better, you can create a global object and assign instance variables to it (for example, array or dictionary). You do not need to update the values every tick, just check if they are different. if your animations have the same names as the values in the second row of your array, the code should look like this:

    PS: you should not use the first column of your array for labels. something like that is in better hands separately.

  • kriand beat me with the answer, but since I've already typed it I'll post it anyway :)

    In the array editor columns are X axis and rows are Y axis.

    For example, to get "Jump" property of Spring_Helmet, you can use Array.At(1, 4)

    The "FULL NAME" row from your table can be a unique identifier/code of each item. You can use the same code as animation name.

    So to pick a random item from the array you can do this:

    Set local variable randomItem to int(random(1, Array.width))
    ItemSprite set animation to Array.At(randomItem, 1)
    if Array.At(randomItem, 3)>0 : Set P1_Speed to Array.At(randomItem, 3)
    if Array.At(randomItem, 4)>0 : Set P1_Jump to Array.At(randomItem, 4)

    Or you can create a bunch of functions to retrieve different stats from the array, as I did in the example I gave you in one of your previous posts.


    PS: you should not use the first column of your array for labels. something like that is in better hands separately.

    Why not? He just needs to remember that X=0 is reserved for stats names.

    Having this column makes it easier to edit data in the Array Editor. Also it allows to create a universal function "GetItemStat", that will return any stat for any item, say Function.Call("GetItemStat", "short_sword", "damage")

  • Thank you both for the quick reply I appreciate it!

    To be honest this is much more confusing than I thought... I mean without Array Editor.

    I'm totally lost now, I'm scratching my head to understand what's going on on these examples but trying to compare this to my own goal it's very confusing.

    I believe I understand the concept of the variable.width so it will run on the X but I'm still lost on that animation complete and such, because my items have loop animations, and I don't really want to mess with the animations of the items as they are for visual presentation of the sprite only.

    I guess I will try to mess with it and see maybe I'll get a better idea...

    There is always that easier way of doing this of course: split each item to it's own group with it's own conditions on a dedicated Items event sheet to keep everything organized.

    But as I said, I do want to give it a try, unfortunately... I'm just an animator, my brain can't understand these complicated Arrays even with the nice Array Editor (in other words, I'm stupid for this so I'll look for an easier more visual way as I mentioned if I'll fail to understand how it works).

    I bet that your examples are VERY clear to anybody else, but for me it's a total mish-mash in my brain right now so don't get me wrong, thank you for your replies!

    I'll update if there is any other place I'll stuck in.

    Sorry about my bad English and thanks again! :)

  • As you can see from our two examples, there are many ways to do something. Depending on the composition of the rest of your game, one procedure may be better suited than the other. It is important to read about the basics of an object in the manuals and to try out a few things in a separate project in the simplest way.

    With Construct 2, creating one Sprite for every Item and put them all into a family was no option for me, when i made my inventory template. But things are different in Construct 3 since it has the action 'Create object (by name)'. Depending on how the rest of your game is set up, it would be quite an option.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Array.width means the number of elements (or columns) on its X axis. In your case it's the number of items, +1 for the column with labels.

    I meant you should give your animations in the Items sprite the same names as you have in the array - "Spring_Helmet" animation, "Rock_Helmet" animation etc. It will make everything much easier.


    You need to experiment, try other people's projects and tutorials, change different things, see what happens etc. This is the only way to learn in programming.

  • Yes, that's what I meant that I think I understand the x (width) it make sense to me. (Y horizontal raws, Y veritcal raws) and yes I do use the same animation names.

    but the animation complete? I think I'm lost there.. not even talking about the rest of the code hehe

    calling the variables using the arrays and their properties, I'm still trying to understand how it's connected.

    Sorry for my stupidity, I'm trying to practice and learn thanks to your help.

  • That's just the AJAX tag name - "Animations". You can rename it to whatever you like, "ItemsArrayData" for example.

    Tags are needed in case you are requesting multiple files with AJAX and you need to know which is which.

  • OH! OK, it's just the AJAX/ Json loading lines, it's still new to me... as you said, I just put it there and I can ignore it. but it is important to me to understand, so thanks! I understood that the "tags" are to name and use different AJAX files or like I used "tags" in the Audio in Construct 2 long time ago so it's good to understand.

    The rest of the code, I didn't really understand so I tried to copy/past what I saw here, as I said the all Array Editor code is confusing me, which is weird because it is very organized visually... much better than "imagine" arrays, no doubt about that.


    When I pickup the "RANDOMIZER" Item, it will change to a random item, thanks to your help!

    To be honest I don't fully understand it but it's a progress, maybe I need to get used to the Array Editor and Arrays in construst 3 in general.

    So, the "FULL NAME:" and other 0 raw I use are fine for naming if I understood dop2000 correctly, and yes my animations names are just like what I put on the Array Editor (copy past) but it was: "ID_Animation_Name" before I just removed the "ID_".

    Now how do I make the rest of the properties in the Array, for example changing the JUMP on the "Spring_Helmet" to actually change.

    I tried "Every Tick" set platform properties to the global variables.

    Now back to the original thread subject:

    How do I or make the numbers in the Array to "talk" to the variables?

    For example following the raw "JUMP:" in the array editor will always point to the global variable: ?

    "SPEED:" will always point to the speed variable, etc..

    I'll probably edit / change the Array Editor from how it is now, but I want to see if I'm not too far away from making this works thanks to your help of course. [/img] [/img] [/img]

  • See my first comment in this post, there is a code that sets jump and speed variables to values from the array.

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