Function not being executed on first call

0 favourites
  • 4 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Problem Description

    I have a loop that calls a function when certain criteria are met. In my game, once a screw is "unscrewed" a function is called. However, for some reason the function isn't being executed the first time it's called in the loop.

    Attach a Capx

    https://drive.google.com/open?id=0B2mi7Z0OwMDqWjEwMlhkLURBRmc

    Description of Capx

    This is a big project. The issue occurs in the function "addItemToInventory" (look at group "funclib"). The first time the function "checkFasteners" is called inside this function, it does not execute. I tested this by setting up a test var in the function and at the point the function is called. The test var near the call to the function changes, but the test var within the function "checkFasteners" does not until the function has already been called once inside the funtion "addItemToInventory".

    Steps to Reproduce Bug

    • Step 1: Walk up to the door control (WASD) and press "R".
    • Step 2: Click on the screw driver and unscrew each of the screws in the face plate by clicking and holding the tip of the screw driver to the screw.
    • Step 3: The var "test" changes when you remove a screw and which calls the "checkFasteners" function and test2 changes when that function is actually executed. You'll see that test2 only increments after the second screw (and all subsequent screws) are removed.

    Observed Result

    The function is not executed the first time it's called.

    Expected Result

    The function "checkFasteners" should execute each time it's called.

    Affected Browsers

    • Chrome: YES
    • FireFox: YES
    • Internet Explorer: NA

    Operating System and Service Pack

    Win 7, SP1

    Construct 2 Version ID

    239 64-bit

  • I was able to get this working correctly by calling the function in a different location (and it cleaned my code up in the process). But the issue still exists, and I can't explain why the first time the function was called it wouldn't actually execute.

    So, I'll leave it up to you as to whether to close this or not. Thanks.

  • Closing, please see the bug report guidelines. This project has 393 events. In all likelihood you just made a mistake in your events. The Function object is mature and well-tested. If you think there is a bug with it, try to reproduce it in a new empty project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The or event on line 323 is unpicking the function object so no function calls will work. The fix is to instead of using the parameter compare condition, use the system compare function.parameter(2)=0.

    New bug:

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