[PLUGIN] rex_Function2

From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • MTR

    Official Wait action will leave current action until time-out, and it will not reserve the global/local variable ( but SOL will be reserved ).

  • Update

    Add rex_bfunction2 behavior

    A behavior version of rex_function2 plugin, to run a private function of an object. ( sample capx )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I usually use the official function plugin with index parameter, but I could not understand how to get function2 using named parameter.

    I tried the example capx and read the documentaion, but...I don't understand how to use name parameter instead of index parameter.

    Here is what I tried to show X,Y coordinates of the Touch(X,Y), but I get 0,0

    https://dl.dropboxusercontent.com/u/139 ... e0234.capx

    rexrainbow please guide a little shining light in to my life <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Cipriux

    Here is the fixed capx.

  • rexrainbow

    I understand now, thanks. So.. In my example, comparing to the official plugin, there's extra 2 lines of code when calling the function and 2 extra lines of code when defining the function, but that's ok

    Thank you for clearing that out.

    P.S. "declare parameter" and "Set parameter" should be done behind the scene, since I will declare a parameter ONLY if will use it in the function defininition

    I mean, if I use a string instead of number for the parameter index it should be acting like the example you provided, without me adding extra lines of code.

    Something similar to "function overload"

  • Cipriux

    "declare parameter" has 3 effects

    1. It maps the string index to index index. The first defined parameter will map to index 0.

    In your case, you also could call function by index parameter (touch.X, touch.Y). Thus this rex_function2 plugin is compatible with official function plugin.

    2. It could give a default value if this parameter was not assigned. You could define a lot of input parameters but only pass some of them.

    3. Moreover, it could check the type of parameter value.

  • hi rex,

    first let me say your plugins are amazing and i use them a lot.

    i have 2 suggestion for Function2M.

    1) timer plugin like support

    how it looks now:

    start Timer "A" 1 sec

    on Timer "A"

    call func:"A"

    the problem:

    the code is very messy,

    i do not want to use system wait -> you cannot stop it, and it saves the entire object filter in memory.

    how to fix:

    add new actions:

    call function with a timer (once or looped) (with / no params)

    stop timer

    ---------------

    2) delegate support

    how it looks now:

    layoutstart:

    call func: "A" (delB)

    call func: "A" (delC)

    on func "A" :

    globalDel <- A.param(0)

    call func: "LongProcess"

    on func "LongProcess":

    call func: globalDel

    the problem:

    the code is very messy, and it will not work if you call 2 delegates at the same time.

    how to fix:

    the function should keep in memory the delegates as special params even after its activation has finished.

    at anytime you can call -> active all delgates(A) , A is the function name.

    *i think the these 2 problems (timer & delegate) should be solved in the plugin level and not the c2 level.

    still the plugin is a great improvement of orginal function, and its great for wanting something closer to "real programming"

  • sagispin

    Thanks for using my plugins.

    1) Timer is another kind of object. I would like NOT integrate timer behavior into function object.

    There are some timer behaviors

    • official timer behavior
    • my rex_timer behavior,
    • or timer in my rex_timeline plugin, which uses official function object for time-out callbacks.

    You might add "system action: wait signal" to pause current actions, in one-shot timer case.

    2) I am not sure what's purpose in your example.

    call "A" ("delB")[/code:5ulxxb4y]
    Here pass function name "delB" into function "A", and
    Do you want to call a function which passed from input parameter?
    Then you could add this function name into parameter like function "A" does.
    [code:5ulxxb4y]call "LongProcess"( Function.param(0) )
    
    on func "LongProcess":
    call Function.param(0)[/code:5ulxxb4y]
  • thanks for the quick response,

    the idea was that function A is responsible for a complex task, B and C act like listeners.

    they want to know when the whole process is finished.

    the process A can mange its listeners by using local variables, and once he finished the task he can active those functions.

    both my suggestion are very possible to do with construct 2 as it is now,

    i just wanted a smoother way to use them to make the code simpler.

    and i will check out those plugins

  • sagispin

    Task or process is another kind of object. I prefer not to integrate task/process into function object, either.

    It is better to have another object/plugin to manipulate task/process, to start or cancel it.

    One possible solution is using my FSM plugin ( or FSM behavior).

    1. Create task -- create a FSM instance

    2. Initial task -- set callback function by function name in private variable of this FSM instance

    3. Run task -- change state with input and private variables

    4. Stop task -- change state to END, run callback

    5. Delete task -- destroy this FSM instance

    Edit: Here is another way to pass function call by using this plugin, which serialize function call into a string.

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