Calling different functions params

0 favourites
  • 3 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I know it's possible to use a param like that;

    Function.Param(0)

    But i have more functions. I tried this;

    Function("Fnc1").Param(0)

    But it didn't worked. How can use different functions params.

    Thanks

  • Param() is used to only get the most recent called function paramaters. Even other langauges don't let you get access to another function's called params. If however you are nesting function calls. Which can and does happen often enough. Then you need to continue to pass the param.

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

    some event

    Call.Function("foo", playerID)

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

    On Function("foo")

    do stuff

    Call.Function("fud", PlayerID, Array[playerID])

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

    As noted, playerID is passed into foo. then foo passes into fud as needed.

    I've never seen a programming language that will let you access params from another function. If there is I could imagine that the language would have lot's of memory leaks and errs. Part of the design of functions is to isolate other params and variables from each other. So cross funtion params seems to work against design.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If I understand you mean something like:

    functionX(varParam = functionZ(X, Y, Z));

    functionZ(X, Y, Z) {

    if(X != null){

    return X;

    }

    if(Y != null){

    return Y;

    }

    }

    If you mean this, I dont know how to do that in C2 but interesting question. I try to find a worktrough.

    Got it tutorial is upcomming ;)

    EDIT:

    Function On "Test"

    -- Chrome Log function.Param(0)

    Funtion On "Test2"

    --IF varWantedParam = 1 //any Condition you wish

    --- Set return value to varParam1 //The parameter you want typically a variable

    --IF varWantedParam = 2 //any Condition you wish

    --- Set return value to varParam2 //The parameter you want typically a variable

    Call "Test"(Function.Call("Test2"))

    If you want to get the Parameter from Test2, just change one line:

    --- Set return value to varParam1 to --- Set return value to function.param(0)

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