Repeating last command from trigger.

Post Reply
valvido
Posts: 11
Joined: Thu Apr 18, 2013 10:48 am

Repeating last command from trigger.

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Repeating last command from trigger.

Post by Vadi »

If your game has a repeat command (IREs have "!" as the command), you could try using that.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Repeating last command from trigger.

Post 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".

valvido
Posts: 11
Joined: Thu Apr 18, 2013 10:48 am

Re: Repeating last command from trigger.

Post 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

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Repeating last command from trigger.

Post 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?

valvido
Posts: 11
Joined: Thu Apr 18, 2013 10:48 am

Re: Repeating last command from trigger.

Post 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

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Repeating last command from trigger.

Post 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 {}

valvido
Posts: 11
Joined: Thu Apr 18, 2013 10:48 am

Re: Repeating last command from trigger.

Post by valvido »

That work!

Thank you!

keresZ
Posts: 8
Joined: Wed May 22, 2013 10:33 pm

Re: Repeating last command from trigger.

Post 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

Post Reply