Page 1 of 1

Repeating last command from trigger.

Posted: Mon May 20, 2013 11:09 pm
by valvido
Hi,

Is it possible to repeat the last send command based on a trigger?

Scenario:

Trigger 1 caused SEND("stuff").

Trigger 2 caused a repeat of what Trigger 1 sent.

Re: Repeating last command from trigger.

Posted: Mon May 20, 2013 11:37 pm
by Vadi
If your game has a repeat command (IREs have "!" as the command), you could try using that.

Re: Repeating last command from trigger.

Posted: Tue May 21, 2013 12:19 am
by Jor'Mox
You could store things as you send them in a global variable to keep track of the last command you sent (as opposed to the last command sent to the mud, which could be from user input). Then just reference that.
Like this:
Code: [show] | [select all] lua
last_sent = "stuff"
send(last_sent)
Then your second trigger can use the value stored in "last_sent".

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 2:53 pm
by valvido
I can't seem to get it working, can someone help fixed my code?

Trigger type: Perlreg.
Line:

Code: Select all

John tells the group, 'Entr (\w+).'
[\code]

Code:
[code]
entrance.name = matches[2]

send("entrance "..entrance.name)
[\code]

Sample mud output:
[code]
John tells the group, 'Entr Lawson.'
[\code]

I should send to mud entrance Lawson

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 3:04 pm
by Jor'Mox
So, let me get this straight, your trigger pattern is this:
John tells the group, 'Entr (\w+)\.'
(Note that I escaped the period to make it actually check for a period in your pattern, instead of any character.)
And your code is this:
Code: [show] | [select all] lua
entrance.name = matches[2]
send("entrance " .. entrance.name)
But you can't make it work. First, are you getting any output at all? If not, it is likely that your trigger isn't firing. If you are getting output, what are you seeing?

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 5:30 pm
by valvido
That is correct. Here is the pictures of the Trigger and Debug screen. I don't understand the error I am getting in the Debug.

http://imgur.com/a/SV5Pw

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 5:49 pm
by Jor'Mox
Oh. The '.' syntax you are using indicates that "entrance" is a table, and name is an index for that table. But entrance is not being declared as a table, hence the error.try using "entrance_name" instead of "entrance.name", and it will work perfectly. Or you can declare entrance as a table like so:
Code: [show] | [select all] lua
entrance = entrance or {}

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 5:56 pm
by valvido
That work!

Thank you!

Re: Repeating last command from trigger.

Posted: Thu May 23, 2013 6:39 pm
by keresZ
Vadi wrote:If your game has a repeat command (IREs have "!" as the command), you could try using that.
wow what a nifty tip! thx, I probably would have never found that otherwise