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

Discussion and feedback on Construct 2

Post » Wed Nov 26, 2014 3:49 pm

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!
B
18
S
5
Posts: 80
Reputation: 1,338

Post » Wed Nov 26, 2014 4:06 pm

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.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Post » Wed Nov 26, 2014 6:14 pm

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!
B
18
S
5
Posts: 80
Reputation: 1,338

Post » Tue Dec 02, 2014 2:50 am

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?
B
18
S
5
Posts: 80
Reputation: 1,338

Post » Tue Dec 02, 2014 8:18 am

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. :lol:

@Ashley ???
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Tue Dec 02, 2014 8:43 am

TiAm wrote: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. :lol:

@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.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Tue Dec 02, 2014 9:02 am

Aphrodite wrote:
TiAm wrote: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. :lol:

@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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Tue Dec 02, 2014 12:32 pm

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.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Post » Sun Jan 11, 2015 11:24 pm

Ashley wrote: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)
B
18
S
5
Posts: 80
Reputation: 1,338


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests