[PLUGIN] rex_Function2

  • Geo

    SOL is "selected objects list".

    nothing will be pre-filtered, and no filter that the function does is kept past its scope.

    That is SOL, to decide which instances to be operated. For example,

    Event function called "destroySprite"
        action: sprite -> Destroy

    What instances do you expect to be destroyed?

    Test case A.

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/screen2-9.png" border="0" />

    In "test" function, it will destroy all instances of sprite object. i.e. the SOL of sprite object in "test" function contain all instances.

    Test case B.

    Creating instance before call "test" function.

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/screen3-2.png" border="0" />

    The SOL of sprite object in "test" function only contain the new instance. So only one instance had been destroyed.

    The function body is the same, it does the same operation to different instances. Function plugin does not select which instances should participate in these actions. It depend on what you do before calling function (and the design of engine).

    --

    The SOL confuse me sometime, too.

  • Hey, I'm trying to do something like this in C2:

    <img src="http://dl.dropbox.com/u/919275/Screenshots/AOD/CalculateAngleClassic.png" border="0" />

    Problem is, functions can't be called within functions. And the lack of an "else" condition means it's impossible to check whether a function is NOT being called, due to the nature of how the plugin works. Trying to replace the function with a variable work-around doesn't, well, work, or at least not very well.

    Would it be possible to implement a solution to these issues?

  • Candescence

    I can catch if a function is NOT being called. Could any one provide a name of this condition?

  • How about "Function <Name> Not Called"? Might be better names for it, but it's the best I can think of right now.

  • Candescence

    I will think about implementation of recursion call.

  • Thanks! I would really appreciate it! :)

    Also, I think I discovered the reason why the Construct Classic version of the engine I'm trying to replicate placed a function within a function - for some reason, the "else" wouldn't work unless it was sub-event! Hilarious, really.

  • Candescence

    Here is a beta version of function plugin with recursion supporting, and a test capx.

    I add a memory stack to support recursion and test it by factorial calculation in capx.

    This can calculate factorial correctly.

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/correct.png" border="0">

    However, this can not.

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/incorrect.png" border="0">

    Event sheet is not designed for recursion, so some styles will not cause correct result.

    Sorry, I failed.

  • Candescence

    Function can be called in other function like

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/fn.png" border="0">

    I had fixed nested call bug before

  • Candescence

    I check "Else" in your picture. C2 can not put triggered condition under other condition anymore.

    I would like to add "No triggered function" (or other name if possible) after "action:call function".

    - action: call function
    + condition: No triggered function
        - do something

    It can do something if no matched triggered function in event sheet.

    What do you think?

  • OK rexrainbow, I looked into this thing some more. There is something that I can't understand, can you please have a look at this simple capx.

    Repro:

    1. Open capx and run the game.

    2. In the game, click the Continue button.

          - it says "You lose, 4 enemies still alive"

    3. Go back to Construct 2, on the event sheet there is a disabled action "system wait 0 seconds". Enable this action

    4. Run the game again

    5. Click Continue button

          - this time it says "You win, all enemies destroyed"

    This is what troubles me. The sprites should get destroyed before the function gets called, regardless of the wait 0 seconds.

    The function call just counts the enemies and displays a message.

    Can you help me figure this out? Why does the count return 0 with the wait, and 4 without the wait?

    Thanks.

  • OK, I did even more investigation. This has nothing to do with the functions, it has to do with how the Destroy action works and what happens to the SOL.

    I opened another thread here, you can ignore my previous post. The same thing happens even without functions.

    Thanks again!

  • Alright, let's go with implementing "No triggered function" for now. For all we know, putting a function inside a function may not even be necessary. It was structured that way in Classic probably because putting an else as a non-sub-event caused an error in this case for no apparent reason.

  • I don't know why this isn't standard functionality, but your plugin literally revolutionized the way I approached designing games with C2. Your plugins really are amazing for productivity, but your function plugin is the crown jewel of that fine collection.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mrabear

    Ashely will make official "function" feature in the future.

  • Great work Rex, love the function feature - I'll be using it for just about every project from here onwards.

    I was just wondering, is there a function that allows you to pass objects/sprites to it? I seem to have to copy & paste quite a bit when I need to apply the same rule types to different object/sprites.

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