How to trigger a rule only once?

stefdelecstefdelec Member, PRO Posts: 146
edited September 2015 in Working with GS (Mac)

Hi,

I am making a gameword, and I want the letter to spawn according to the letter around. One letter per actor. So I made several rules. But letter are keeping changing after the first time they spawn/appear. How can I be sure that when a letter spawn and a letter is assigned to an actor, it doesn't change afterward.

I think there is something I have not understood with rule and change behavior.
For example:

If x= 0 => change attribute to true,
otherwise change attribute to false.

Let say during the game for a reason, x is changing to another number than 0, it will trigger "otherwise". Am I right?

Basically, I want the rule to be triggered only once, when it appears. And that all. Should I put a boolean "rule triggered"?

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Yes just create a self attribute and use it as a lockout.

  • stefdelecstefdelec Member, PRO Posts: 146

    Tks.

  • stefdelecstefdelec Member, PRO Posts: 146

    I have done it, and I don't understand at all but it keeps not working.

    I have included a boolean.
    If letter assigned false=> trigger rule.
    [
    Inside the rule, I said if parameter 1 =>assign a letter And change attribute boolean letter assigned/
    otherwise 'rule if parameter 2'=> assign a letter And change attribute boolean letter assigned/
    otherwise assign a letter And change attribute boolean letter assigned.
    ]
    (assign a letter in 3 different manners).

    So it shouldn't be changing again or do I have a logic error.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I'm confused what rule do you only want to fire once. The main rule or the rule in the otherwise section?

  • stefdelecstefdelec Member, PRO Posts: 146
    edited September 2015

    Any of these which assign a letter.

    When letter is assigned, don't change it! :-)

    The 3 parameters:

    • If there is too many voyels,
    • if there is too many consomne
    • None of the above.

    According to these 3 parameters, it assign a letter to the actor, and it doesn't change even if "voyels" consomne"...etc changes.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited September 2015

    That doesn't help me as I don't know your code or overall game logic. Post a screen shot of the code your talking about.

    Here is how I would do it. Create a self attribute in the actor or actors call it lockout.

    Rule

    If all

    Condition you have that fires the rule. Self.lockout is false

    Behaviors that are in the rule.
    Change attribute self.false to true

    Otherwise

    Rule

    If all

    Self.lockout is false

    All the code you have in otherwise inside this rule.

  • stefdelecstefdelec Member, PRO Posts: 146
    edited September 2015

    I m not sure it gonna help.... :-)
    I am sending a new screenshot as this one is not good.

  • stefdelecstefdelec Member, PRO Posts: 146

  • stefdelecstefdelec Member, PRO Posts: 146
    edited September 2015

    Yes, it is what I have done, (I think) but it is keeping changing.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I would abandon the idea of using otherwise and do it all as straight conditional logic.

  • stefdelecstefdelec Member, PRO Posts: 146

    Ok. I ll do.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Using otherwise can be tricky. Your logic will be easier to control without the otherwise kicking in.

Sign In or Register to comment.