Best way to make Custom Trigger?

0 favourites
  • 7 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • I want to make a custom trigger without making a bool and using Trigger Once, is it possible? without an addon? seems like this is something that should exist in Construct no?

  • I mean.... trigger once is a thing that exists in Construct without an addon that lets you define your own trigger conditions...

  • Groups.

    ...ehhh

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • oosyrag yeah but I have to make a condition true in order for it to fire and then I need to reset the condition so it can fire again...

    I tried out that Finite State Machine Addon and its basically the functionality I am looking for. I'm just wary about using addons too much.. I'm already using some..

  • Include the reset action in the triggered event? Seems like that would be how a trigger would be built.

  • You can make the trigger once with a variable and some events.

    Variable bool=false
    
    Condition
    — if Bool=False
    — — set bool to true
    — — do something
    Else
    — set bool to false

    But since you want to reset things you could utilize a dictionary or array which would make less variables all over

    Condition
    — if negated dictionary.hasKey("trigger1")
    — — dictionary: add key “trigger1” with value 0
    — — do stuff
    Else
    — dictionary: remove key “trigger1”

    You just have to have a unique key for each clump of events. And making it reset would be a matter of deleting that key.

    There may be a way to simplify that further. If the conditions can be just expressions then you could do one liners with a function.

    On function trigger
    - Param text key
    - Param number c
    — set return to 0
    — c <> 0
    — — negated dictionary haskey key
    — — — addkey key with value 0
    — — — set return to 1
    — else
    — — removeKey key
    
    
    Compare: function.trigger(“trigger1”, sprite.x>100) =1
    — do stuff
    
    Compare: function.trigger(“trigger2”, sprite.y<200) =1
    — do other stuff
    
    On any key pressed
    — deleteKey “trigger1”

    Anyways, just some contrived examples.

  • yeah I guess this works, and I just set it the bool to true when I add to the cue, so it will fire off this trigger. I'm just being picky...it just doesn't read as well to set something to true and then know its only triggering something once.

    What will happen in this trigger is it checks an array of messages, displays them, then when the message is done, it then checks again if there is another message in the array. Message length (time) and actions vary. So it was necessary to cue them up in an array to which I push and pop them as I go.

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