0 Favourites

How do I Find events that are not used?

  • 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

  • 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.

  • 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.

  • 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.

  • > 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.

  • 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.

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • yes it happened to me as well, deleting an object will delete the events

  • 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

  • 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!

  • It does give you this

    [attachment=0:gvk47yih][/attachment:gvk47yih]

    Are you saying you want to be told of every individual line of code?

  • I suppose I would love to have that as an option. It could also highlight every line that would be changed on the current sheet, before I hit the Yes button. Honestly, I'm not sure if it does. I only ran into the problem last night cleaning up an example for someone that had lots of unneeded objects. It was easy to get the line I needed back and then edit that variable out of the line of code before re-deleting the object.

    It shouldn't be much extra work on my part to simply do a search on the object before deleting. I assume it would be a lot of effort to change the editor, with little added functionality.

    Getting back to the original question:

    It does not notify you of unused events (events whose condition never evaluates to true?)

    Does it let you know when your Function is never used? That seems reasonable in a traditional language.

    I should have turned to this forum long ago. Great community, lots to learn from.

  • agreed with arrall, that would be good adition

  • I'm thinking of making a tool that would do this, and other things that people are asking for. I wonder if people would be interested. Of course an external tool is never as nice as integrated.

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