Place sub-event before main event actions

Get help using Construct 2

Post » Fri May 17, 2013 10:34 pm

Hi, I couldn't find the answer by searching.

I'd like to make my sub-event trigger immediately after the event fires, then do then perform the main event actions.

For example:

Preferred:
Event: Buttmode == True
etc conditions...
Sub-Event: ExtraButt == True
    Sub-Event Actions: ButtPoints += 1000
Main Event Actions: ButtPoints += 10
                      ButtMode = False
                      ExtraButt = False

How it is now:
Event: Buttmode == True
etc conditions...
Main Event Actions: ButtPoints += 10
                      ButtMode = False
                      ExtraButt = False
Sub-Event: ExtraButt == True
    Sub-Event Actions: ButtPoints += 1000

If main event actions fire first, then the sub-event won't fire because ButtMode is assigned to false. How do I move the sub-event up before the main event actions?

Thanks!CannedEssence2013-05-17 23:01:42
B
8
S
1
Posts: 49
Reputation: 615

Post » Fri May 17, 2013 10:42 pm

Did you try this to confirm that the sub event won't fire?

I'm not positive, but I thought that once the main condition is met then all events and sub events proceed even if something happens to counter the original condition.


Event: Buttmode == True
etc conditions...
    Main Event Actions: ButtPoints += 10
                      ButtMode = False
Sub-Event: ExtraButt == True
    Sub-Event Actions: ButtPoints += 1000


The condition that would be messed up by what you describe would be something like a while condition.
B
4
Posts: 5
Reputation: 305

Post » Fri May 17, 2013 11:00 pm

Sorry, let me revise my original example. I got carried away with the butts. Add an action to main events where ExtraButt is also assigned to false
B
8
S
1
Posts: 49
Reputation: 615

Post » Fri May 17, 2013 11:10 pm

Event: Buttmode == True
Sub-Event: ExtraButt == True
    Sub-Event Actions: ButtPoints += 1000
Sub-Event: (empty)
    Sub-Event Actions: ButtPoints += 10
                      ButtMode = False
                      ExtraButt = False

I'm not sure I understood your events, but I guess this would work.
There are two sub-events to the main event, and one fires right after the other.
If ExtraButt == True, then it adds 1000 points, and right after it runs the second sub-event, which adds 10 points and sets everything to false.
If ExtraButt == False, then only the second one fires
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Fri May 17, 2013 11:16 pm

Hmm... I guess an empty sub-event would do the trick... I'm just getting into this, and somehow I'm kind of scared of the "tricks" I'm going to have to do.

Thanks for the suggestion!
B
8
S
1
Posts: 49
Reputation: 615

Post » Fri May 17, 2013 11:35 pm

Whats wrong with a function, and/or a wait?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri May 17, 2013 11:53 pm

[QUOTE=newt] Whats wrong with a function, and/or a wait?[/QUOTE]

So, you're suggesting with a function I would do:

Event: Buttmode == True
etc conditions...
Main Event Actions:   CheckForExtraButt()
                      ButtPoints += 10
                      ButtMode = False
                      ExtraButt = False

Function ExtraButt()
    Event: ExtraButt == True
      Actions: ButtPoints += 1000

Is that correct?

With that workflow I would have a separate function for each simple if condition I needed to check before the other actions.

Not sure what you mean by a "wait". Are you saying to add to the main event's conditions a wait .5 seconds or something? So that the sub-event gets asynchronously checked?

Thanks for all the tips
B
8
S
1
Posts: 49
Reputation: 615

Post » Sat May 18, 2013 12:02 am

You should post your CAPX. This will go faster without the pseudo code.
ImageImageImage
B
67
S
19
G
122
Posts: 3,206
Reputation: 73,399


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, Axiomaltd, MACPK, nicklowkcmagic, OddConfection and 22 guests