How do I Find events that are not used?

Get help using Construct 2

Post » Sun Nov 16, 2014 8:14 pm

Hi, imagine you have a game with many many events. You made many modifications and changes and now its time to get rid of events that do nothing . Does exist any plugin or something that will find unused events and objects in project?

I have tried to search one line by one, and i saw some events i thought they do nothing so i stupid deleted them instead only disabling them, And uhh bug. And this one by one is tedious. So any tool that will search for unused events would be great
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 8:56 pm

Unfortunately, reliably finding unused code(Construct or otherwise) is a difficult problem without a general solution, as to catch everything you would have to test all possible input combinations, which is unfeasible.

What I suggest is to adopt solid code organization practices. For example, making extensive use of the function object. This allows for code reuse and good logical encapsulation. In addition, it's much easier to find if code in a function is being executed, as you merely have to check if the function is being called from anywhere -- there's no automatic way(as far as I'm aware) to check this, but it's much easier to check manually than without the use of functions.

Additionally, making smart use of groups is an excellent way to group code that is logically related. By keeping related code together physically, it's much easier to see if a piece code has been replaced, made redundant, etc. Strewing logically related components through a large event sheet is going to lead to confusion and make the project harder to extend in general.

As for checking for unused objects, the pay version of Construct 2 has an event search feature which you could use to search for references to objects, which would greatly help in determining which objects are being used.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Sun Nov 16, 2014 9:08 pm

Unless I'm mistaken the event search feature only searches the active event sheet, which makes it less than useful when following code organization practices such as including multiple event sheets.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Nov 16, 2014 9:15 pm

codah wrote:Unless I'm mistaken the event search feature only searches the active event sheet, which makes it less than useful when following code organization practices such as including multiple event sheets.

Granted, but I was suggesting it as more of a helpful tool -- it's still preferable to looking through event sheets manually for references to objects.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Sun Nov 16, 2014 9:33 pm

linkman2004 wrote:
codah wrote:Unless I'm mistaken the event search feature only searches the active event sheet, which makes it less than useful when following code organization practices such as including multiple event sheets.

Granted, but I was suggesting it as more of a helpful tool -- it's still preferable to looking through event sheets manually for references to objects.


Only just ... the search features are really in need of improvement. Both simple search and reference search. Hopefully there will be time to give these features some love.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Nov 16, 2014 9:50 pm

And one more thing. Only example. What if i have 1.001gb of images in my project and only 1mb is used in the game. Will construct export my game including the 1Gb of unused images?

The same aplies to unused Event sheets.
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 10:11 pm

From what I see, if the image is in your project, it gets exported, regardless if it is used on any layouts. C2 will even warn you when you delete the last instance of an image/sprite from a layout that it is still included in the project.

Also, when you delete something out of your object types, C2 deletes it entirely. This can cause lines of code to disappear in my experience.
B
6
S
2
Posts: 37
Reputation: 524

Post » Sun Nov 16, 2014 11:07 pm

yes it happened to me as well, deleting an object will delete the events
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Sun Nov 16, 2014 11:14 pm

arrall wrote:Also, when you delete something out of your object types, C2 deletes it entirely. This can cause lines of code to disappear in my experience.


No point referring to something that doesn't exist :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Nov 16, 2014 11:25 pm

Yep. I don't know how else the editor would handle it really. I suppose I just wish it would warn me individually when one of my lines of code referencing multiple objects' parameters gets deleted because of an object deletion, rather than silently deleting the entire line of code.

Other languages/IDEs do detect unused variables and functions, and warn you. I am not expecting that in C2 because the structure of your project is not just lines of code. I do look forward to improved autocomplete though!
B
6
S
2
Posts: 37
Reputation: 524

Next

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 8 guests