[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Triggers that trigger again.

Triggers that trigger again.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Jlyrncher   (6 posts)  [Biography] bio
Date Sat 04 Mar 2017 09:24 AM (UTC)
Message
So I'm trying to write some autotrain triggers for "Realms of Despair."

I would like to keep trying a command I have entered until success is achieved.

For example:

I enter "cast 'black hand' naga" but the spell fails and I recieve the response from RoD is "You lost your concentration."

I wrote a simple trigger to retry the last command:

<trigger
bold="y"
enabled="y"
keep_evaluating="y"
match="^You lost your concentration\.$"
match_bold="y"
regexp="y"
repeat="y"
send_to="12"
sequence="100"
>
<send>Send(GetCommand())</send>
</trigger>

The problem is it only triggers once. If the mud then responds to the input from the trigger with "You lost your concentration." the trigger will not fire again.

This should keep trying until the message "You lost your concentration." is NOT received as a response, but it only happens once.

I must be missing something. Any ideas?

Thanks.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 04 Mar 2017 10:06 AM (UTC)
Message
GetCommand() returns the current command in the command window which would probably be blank once you sent it.

You could probably use:

Template:function=GetCommandList GetCommandList

The documentation for the GetCommandList script function is available online. It is also in the MUSHclient help file.



If you specify 1 as the argument you get the last command (actually a table with one entry). You could use that to find the last thing you sent.

Of course, if you type something else inbetween then that will be the last command.

You might make an alias the remembers the last thing you tried to do (eg. the spell you cast) and then your trigger can send that again.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jlyrncher   (6 posts)  [Biography] bio
Date Reply #2 on Tue 11 Apr 2017 09:55 PM (UTC)
Message
Thanks Nick. I'm sorry about the long delay in responding. I'm only a "sometimes" programmer. LOL.

I modified the triggers to something like this:


  <trigger
   enabled="y"
   group="Mage"
   keep_evaluating="y"
   match="You lost your concentration."
   send_to="12"
   sequence="100"
  >
  <send>local Command = GetCommandList ( 1 )

Execute (Command [1])</send>
  </trigger>



They still will not fire the second time though. Am I missing a setting or something?

Thanks!
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #3 on Sun 23 Apr 2017 06:01 AM (UTC)
Message

  <trigger
   enabled="y"
   group="Mage"
   keep_evaluating="y"
   match="You lost your concentration."
   send_to="12"
   sequence="100"
  >
  <send>(GetCommandList (1))</send>
  </trigger>


Should do what you want.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Jlyrncher   (6 posts)  [Biography] bio
Date Reply #4 on Fri 28 Apr 2017 04:25 PM (UTC)
Message
Thanks Meerclar

Sorry, but that doesn't work. The purpose of the local variable was because directly calling GetCommandList() returns the table ID not the value.

I'll keep working on it.

Thanks
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 29 Apr 2017 05:07 AM (UTC)
Message

  <send>(GetCommandList (1))</send>


You would need to send it. eg.


  <send>Send (GetCommandList (1))</send>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jlyrncher   (6 posts)  [Biography] bio
Date Reply #6 on Sat 29 Apr 2017 06:49 AM (UTC)
Message
So this if the current code:


  <trigger
   enabled="y"
   group="Mage"
   keep_evaluating="y"
   match="You lost your concentration."
   send_to="12"
   sequence="100"
  >
  <send>Send (GetCommandList (1))</send>
  </trigger>


And this is the current output:

Quote:

c farsight
You lost your concentration.
table: 00B57350

>Huh?


Remember, I'm only a part time programmer. Lua is new to me. I thought that a local variable was necessary. Am I incorrect?

Thanks again.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Sat 29 Apr 2017 10:05 AM (UTC)
Message
OK, this line returns a table with one entry:


  <send>Send (GetCommandList (1))</send>


So change it to:


  <send>Send (GetCommandList (1) [1])</send>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,873 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]