Add a local variable to a function

Get help using Construct 2

Post » Thu Jul 25, 2013 10:18 pm

if you define a new function, e.g.

function On "test"

then you want to add some local variables. However you try and add them, they always come out as global variables. Very frustrating.

How do you add local variables to a function?

I have seen how you can add them to a sub-event, but that's too late, I need to defined them before any of the sub events trigger, as they are set in the action of the function definition (i.e. used before they are defined!)
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Thu Jul 25, 2013 10:22 pm

Add a blank sub-event, add your local there, and do your action there.
ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,847

Post » Thu Jul 25, 2013 10:26 pm

Wow, I had no idea you could legitimately use a blank sub event, I thought they were just temp placeholders for pasting in real sub event code.

Great, that works!
B
17
S
6
G
3
Posts: 370
Reputation: 3,942

Post » Thu Jul 25, 2013 10:28 pm

[QUOTE=nutmix] Wow, I had no idea you could legitimately use a blank sub event, I thought they were just temp placeholders for pasting in real sub event code.

Great, that works![/QUOTE]

Blank sub-events are equal to "Every tick" when used
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Thu Jul 25, 2013 11:14 pm

Blank events are optimal at times.

ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,847


Return to How do I....?

Who is online

Users browsing this forum: unxcellent and 9 guests