Help with trigger

Posted by Xandler on Sun 04 Jul 2021 03:16 AM — 3 posts, 14,287 views.

#0
I am trying to work on this trigger so it happens before I move onto the next room and not get hit by the NPCs, but I can't seem to quite figure it out. Currently it stands as such

<triggers>
<trigger
   enabled="y"
   expand_variables="y"
   group="mobstomove"
   match="You let everyone know that you're ready."
   regexp="y"
   send_to="12"
   sequence="100"
>
<send>

   if @ppl &lt;= 60 then
      Execute ("tranquil")
      Send ("power up")
      Send ("power up")
      Send ("power up")
      Send ("power up")
      Send ("power up")
      Send ("sense @target")
   else
      Send ("sense @target")
   end

   if @pki &lt;= 15 then
      Execute ("tranquil")
      Send ("Swallow senzu")
      Send ("sense @target")
   else
      Send ("sense @target")
   end

</send>
</trigger>
</triggers>


This is causing it to double send the sense line on the match trigger (which I don't want, I want it to fire once regardless). If one variable is less than or equal to 60, it executes the alias then sends power up 4 times, then senses the target, else if pki is less than or equal to 15 it executes the alias, then swallows the bean and then sense the target variable, otherwise it just senses the target variable if neither are true. Do I have this written out backwards? I have it written out on a different trigger and it works well (I want it on a different trigger because sometimes I get hit and it doesn't work properly).

The working trigger is:


<triggers>
<trigger
   back_colour="8"
   enabled="y"
   expand_variables="y"
   group="mobstomove"
   match="Visible Exits:"
   match_back_colour="y"
   send_to="12"
   sequence="100"
>
<send>

   if @ppl &lt;= 60 then
      Execute ("tranquil")
      Send ("power up")
      Send ("power up")
      Send ("power up")
      Send ("power up")
      Send ("power up")
   else
      EnableTriggerGroup ("mobstokill", true)
      EnableTrigger ("moveto", true)
   end

   if @pki &lt;= 15 then
      Execute ("tranquil")
      Send ("swallow senzu")
      EnableTriggerGroup ("mobstokill", true)
      EnableTrigger ("moveto", true)
   else
      EnableTriggerGroup ("mobstokill", true)
      EnableTrigger ("moveto", true)
   end

</send>
</trigger>
</triggers>


I imagine this is double firing as well, but it's just turning on groups so I don't see it. How do I do about fixing the first trigger? Am I missing something simple?
Amended on Sun 04 Jul 2021 08:31 PM by Fiendish
USA Global Moderator #1
Quote:
If one variable is less than or equal to 60, it executes the alias then sends power up 4 times, then senses the target, else if pki is less than or equal to 15 it executes the alias, then swallows the bean and then sense the target variable, otherwise it just senses the target variable if neither are true.

This is not what you've done, though. There's no "else" between your two variable conditions. Look at the placement of your ifs elses and ends. It will help following the logic if you use proper indentation and blank lines between sections.

[EDIT] I've edited your post to include sensible indentation and line breaks for you. Hopefully now you can see how your description does not match the code you wrote.
Amended on Sun 04 Jul 2021 08:33 PM by Fiendish
Australia Forum Administrator #2
You can do a "return" in your logic if you don't want it to do anything after a particular point.