Triggers that trigger again.

Posted by Jlyrncher on Sat 04 Mar 2017 09:24 AM — 8 posts, 33,964 views.

#0
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.
Australia Forum Administrator #1
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.
#2
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!
USA #3

  <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.
#4
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
Australia Forum Administrator #5

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


You would need to send it. eg.


  <send>Send (GetCommandList (1))</send>
#6
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.
Australia Forum Administrator #7
OK, this line returns a table with one entry:


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


So change it to:


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