Local variable in an Event - and jump to a Function...

Get help using Construct 2

Post » Thu Jul 23, 2015 7:09 pm

If I set a Local Variable in an Event and then Call a Function ( jump to a function )
is the Local Variable lost - for the next coming actions.

Like... if I have an Event..
Sets a Local Variable
then in my actions I have like. Call Function"...."
And next action Set "something" to "LocalVariable"

Did the local variable got lost when Construct performed the FunctionCall ?
I mean Construct jumped to another "location" in the code and back again - and I have a situation where I feel this phenomenon happened to me.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Thu Jul 23, 2015 7:20 pm

local variables can only be accessed in their scope. A local variable's scope is its level of sub-events. All other events at the same level of indentation, or lower levels, can access the local variable. Events above it (less indented) cannot access the local variable. https://www.scirra.com/manual/83/variables

You can try "call function"test"(param0=localvariable)
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Thu Jul 23, 2015 8:05 pm

Ok, thanks... :)

Then this is my problem.

Yep That's pretty much what I did.
I called a function and sent the local variable as a parameter - the function got 0
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Thu Jul 23, 2015 8:34 pm

Do you want to do something like this?
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816


Return to How do I....?

Who is online

Users browsing this forum: justifun and 9 guests