Calling different functions params

Get help using Construct 2

Post » Wed Mar 13, 2013 2:42 pm

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
B
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Wed Mar 13, 2013 3:13 pm

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.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Wed Mar 13, 2013 3:25 pm

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)
localboss2013-03-13 16:06:43
B
15
S
6
G
6
Posts: 512
Reputation: 5,550


Return to How do I....?

Who is online

Users browsing this forum: fredriksthlm, MPPlantOfficial and 19 guests