Variable replacement

0 favourites
  • 8 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello I would have a feature request.

    I spent about 1-2 hours today by replacing variables in complex blocks of code by new variable types.

    Example:

    x0+x1+x2+x3... (setting up huge blocks of code involving variables)

    ,,Oh wait, this does not work. I have to use a global variable. Or a local one instead. Or maybe better to use an instance variable. Oh noes I have to change hundreds of lines of code which contained the old variables. D:"

    This was the scenario I had about 2 times today. It would be really usefull if construct had a feature which would allow the user to replace a variable and all it's references with a new one. Or a feature to find and replace specific peaces of code in an event sheet.

  • Hello I would have a feature request.

    I spent about 1-2 hours today by replacing variables in complex blocks of code by new variable types.

    Example:

    x0+x1+x2+x3... (setting up huge blocks of code involving variables)

    ,,Oh wait, this does not work. I have to use a global variable. Or a local one instead. Or maybe better to use an instance variable. Oh noes I have to change hundreds of lines of code which contained the old variables. D:"

    This was the scenario I had about 2 times today. It would be really usefull if construct had a feature which would allow the user to replace a variable and all it's references with a new one. Or a feature to find and replace specific peaces of code in an event sheet.

    I suggest you organize your code to have an easier time editing this.

    Also global variables are really something to use only when needed, I'll always try to have a local static variable or instances variable first.

    Also if you have complex calculation, I'd recommand using functions so the calcul is written once on the entire project, but called multiple times (so you only have to edit once), It'll also be easier to read.

    (For your suggestion to find and replace, there is a research function for the events sheet, but I think it is for non-free versions only)

  • I know how to use variables, but thanks.^^

    The huge block of code already was in a (complex) function. I first used local variables to safe ram but then realised, that I needed global variables instead. Because no other event could acces that variables. It was a careless mistake but this can happen if you are not an experienced programmer. And this is constructs target group.

    So it was just a suggestion as it would sometimes make things easier, if you make a mistake.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I know how to use variables, but thanks.^^

    It was just an example. The huge block of code already was in a (complex) function. I first used local variables to safe ram but then realised, that I needed global variables instead. Because no other event could acces that variables. It was a careless mistake but this can happen if you are not an experienced programmer. And this is constructs target group.

    So it was just a suggestion as it would sometimes make things easier, if you make a mistake.

    You should be able to drag them out of the function I think

  • This is true but it would have deleted all code which has this variables as references (so the whole function). I had to manually change each variable name to the new, global ones. x(

  • trust me, each variable likely consumes no more then a kilobyte of RAM

    a typical computer/mobile device has at least a gigabyte of RAM.

  • In some cases It wouldn't have, like this one:

    I just dragged otherValue outside, and everything stayed, because the expression still works

  • ryackov

    I trust you.

    Aphrodite

    Thank you for trying it out. But this was not exactly what I had to do. I had to completely delete the local number (in your case) "value" and replace all parts where it had been with the new variable. In your case "otherValue". The same procedure for all 10 variables.

    Oh... I think I now got what you did... . You just dragged the variable out of the group and it automatically changed to a global variable? oO

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