Quick way to increment Condition values?

0 favourites
  • 6 posts
From the Asset Store
A challenging game that needs quick responses!
  • Just wondering if I'm missing a hotkey or quick way to do this. I have some basic conditionals to check if a value is a given number, to represent sequential steps of user instructions. It's like changing the text depending on what page a user is reading.

    I'm doing a LOT of copy/pasting since the instructions are mostly the same (if x = 12, change text to ____), so I did a lot of copy/paste. But then each condition has the same value (if x=12, ...., if x=12,...). I'm going through 1 by 1 and incrementing the values for each conditional, but manually this is a lot of clicking into the parameter window, clicking down on the condition to check, typing in a new number, and hitting enter. I have something like 60 "pages", so this takes a while.

    I got it done, but for future reference is there a way to automatically increase/increment the conditional values from the Event Sheet? Or would this be a possible feature for the future? i.e. I copy the event for x=1, 10 times, and it automatically does x=2, x=3, etc.

    I might just be spoiled by Excel, which does this sort of auto-incrementing very nicely!

  • It's not really limitations on the event sheet but the approach you've taken. You could have a global variable TutorialStep that increments each time. Then you can have one event that says 'if TutorialObject.ID = TutorialStep global var, then set text to TutorialObject.text'. So you're pulling the data from the picked TutorialObject when its own ID which you are already using (the TutorialStep instance var) matches the current global variable value to trigger it.

  • I guess that approach feels messier to me since then I end up with 60 objects sitting around rather than 60 checks in a single function, but I get how that would work too.

    I'm gun-shy about global variables because I'm more used to Object-Oriented approaches. I have a "tracker" object that keeps all the variables that WOULD be global. I know functionally it's the same thing, but it feels neater somehow.

  • I would put all the data in an array, the tutorial step would be the index to the array. Then one set of actions can set the text, size and position, and you can completely change the array without having to change any code.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's a really good option too! I hadn't considered using an array to store the values.

  • As AllanR suggested, you should use an Array as json data to store only the required parameters that needs to change, for example 'pos', 'sizex', 'sizey', 'text'.

    Then (to be more organized) create a Function that takes in all these four parameters, that function does all the Three actions you have. Position, Size, and Text.

    Then have a For Loop that runs through the array, and calls the Function with the parameter data.

    Since you're used to Excel, you can also use a csv file to store all the data, and convert that as json.

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