Proposal of name parameter for official function

0 favourites
  • 6 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Some users (actually, it is my team member) said that it would be better to have a name parameter input (name align) for official function plugin.

    I try to propose a solution for this requirement.

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

    1. Prepare input parameter by action:set parameter which gives a string name and it's value, stores them into a {name:value} table.

    2. Call function. In function plugin, put the {name:value} table into stack.

    3. In trigger event, using condition: declare parameter to align name to index, and it's default value.

    • The first declaration name will align to index 0
    • The second declaration name will align to index 1

    ...

    So that the function plugin will have a name to index mapping table.

    And it will try to fill the passing parameter value list.

    Now the plugin has a name to index mapping table, and an extended parameter value list from {name:value} table.

    4. User could use name (or a number index) to get the value under cond:on function.

    Source code of modified official function plugin

    Capx

    This changing will backward compatible for original events.

    I agree that plugin maker should avoid to duplicated plguin from official one. So please consider to implement this name align feature in offical function plugin Ashley .

  • I second that, If it is possible and does not have too many problems, that would be great for complexe mathematical functions, and for any functions really, more easier to understand

  • You can always name a constant global variable "N" with value 0 in your example.

    Instead of having to use the "0" index with less meaning, you can instead replace it with the "N" variable (if that makes more sense to you).

    Example capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Does this really have much of an advantage over immediately unpacking parameters to local variables as the first thing 'On function' does? Both ways you have to create a mapping of index to name, just that this way you do that with conditions instead of actions. Local variables also allow for nicer naming in expressions (n instead of F.Param("n")) and are fast, whereas named parameters will require a lookup.

  • You can always name a constant global variable "N" with value 0 in your example.

    Instead of having to use the "0" index with less meaning, you can instead replace it with the "N" variable (if that makes more sense to you).

    Example capx

    Kyatric : when you call the function, you can set only

    Parameter 0

    Parameter 1

    etc.., it is not like you can set

    Parameter My_Constant_So_Awesome

    I think that is what it is about too

    EDIT: If that is too much, not a big deal I agree (+ninja'd).

  • Ashley Kyatric

    Just like Aphrodite said, user could not assign value by name index when calling a function. It will be difficult to pass values when the function has 20 parameters. (Well, I agree that a function with 20 input parameters is not a good coding style, but my team member still want to do that.)

    The consider of making name align in conditions instead of actions is, I thought it might be more readable since the parameter declarations are more closer to condition:on function , they are at the same block.

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