[suggestion] r190 autocompletes names but don't update them

0 favourites
  • 9 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • I just updated to r190 and I'm really glad for the auto-completion of function names, animation names, etc.

    That being said, I did some test and I was sad to find out that even when using the auto-completion, the names won't update if we change the name of the original, like it would when changing the name of an object or a variable.

    For example, if I create an object "Box" and later decide to rename it to "crate", the name will correctly update everywhere I use it. But if I create a function called "doSomething" and later decide to rename it to "doSomethingElse", the name won't update in all the places I call that function. I have to manually find and replace all the places I used that function, which is tedious.

    I uses function a lot, since they are so practical, and it would be nice to have a way to easily change the name everywhere.

    Thanks!

  • It's not always possible to do this: you can use expressions for names like

    "run" & number

    to switch between names like "run0", "run1", "run2" etc. Then if you rename all of those animations to "walk0", "walk1", "walk2" etc then the editor can't be expected to work out how to update the expression. So it could update the simple cases, but then sometimes it'll still be broken since it only partially updated it...

    One technique is to use global constant variables, which support renaming across the project, and give you one place to update a name in the event sheet.

  • Interesting. I'll try this in the future and see how it goes.

    I anticipate that it will create a huge number of global variables, which might become annoying when trying to find one of my actual variables in the list, be maybe it won't really be a problem. We'll see how it goes.

    Thanks for the reply!

  • Using global variables doesn't seem to work.

    I created a global variable on a separated event sheet. Then in my event "Function On", I wrote the name of my variable.

    That gave me an error message:

    "Parameter must be constant. This parameter only support a value known in advance (it must not use variables)."

    I tried to change my variable to a constant variable, but it gives me the same error message.

    What am I doing wrong?

  • What you are suggesting indeed fails. I think what Ashley was talking about was having constant strings that point to your functions.

    Then, if you changed the name of a function, the only place you would have to update the value would be in the corresponding constant, which could be referenced elsewhere in your code. You would only have to do this for functions that were going to be called in multiple places.

    However, now that I think about it, I don't see why we should be prevented from naming functions with constant global strings...it's not like they are going to change.

    Ashley ???

  • What you are suggesting indeed fails. I think what Ashley was talking about was having constant strings that point to your functions.

    Then, if you changed the name of a function, the only place you would have to update the value would be in the corresponding constant, which could be referenced elsewhere in your code. You would only have to do this for functions that were going to be called in multiple places.

    However, now that I think about it, I don't see why we should be prevented from naming functions with constant global strings...it's not like they are going to change.

    Ashley ???

    Actually, it seems to be due to the implémentation of functions themselves, where each "on function" issue a totally different call (when you call a function, it will not test each function's name then execute, it will only trigger directly said function), that however needs a direct name for the function.

  • > What you are suggesting indeed fails. I think what Ashley was talking about was having constant strings that point to your functions.

    >

    > Then, if you changed the name of a function, the only place you would have to update the value would be in the corresponding constant, which could be referenced elsewhere in your code. You would only have to do this for functions that were going to be called in multiple places.

    >

    > However, now that I think about it, I don't see why we should be prevented from naming functions with constant global strings...it's not like they are going to change.

    >

    > Ashley ???

    >

    Actually, it seems to be due to the implémentation of functions themselves, where each "on function" issue a totally different call (when you call a function, it will not test each function's name then execute, it will only trigger directly said function), that however needs a direct name for the function.

    But...a constant global string won't change. Right?

    Still, I can see the complications of this, most of which would be edittime issues:

      1. What if you change a var from constant to non-constant? What do you do for functions 'named' by that var? Invalidate them? Delete them? 2. What if you create a function called "Foo" and name another function after a constant with the value "Foo"...is the editor supposed to sort all that out?

    I guess that's the thing about a lot of 'simple' requests: implementing them is rarely as easy as it seems.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh, I forgot the editor rejects variables specifically for functions... it should work with animations and everything else though. TiAm is right that one of the problems of allowing even constant variables is if they are edited to be non-constant. Another problem with functions is when should the editor do a rename? If you have two "On function foo" events, and one "Call function foo" action, and you rename one of the two "On function" events, should it rename them all or not? What if you intend to only rename one to make it a different function?

    I think the best solution is a better feature to find/review/refactor across the whole project, so you can easily look up all function events and function calls if you want to rename something.

  • I think the best solution is a better feature to find/review/refactor across the whole project, so you can easily look up all function events and function calls if you want to rename something.

    Yes! Very much yes! I loooove functions, but it's always a pain when I want to rename them (or change the parameters, but that's a whole different issue)

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