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 » Mon May 20, 2013 11:09 pm

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: 4660
Joined: Sat Mar 14, 2009 3:13 pm

Re: Repeating last command from trigger.

Post by Vadi » Mon May 20, 2013 11:37 pm

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

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

Re: Repeating last command from trigger.

Post by Jor'Mox » Tue May 21, 2013 12:19 am

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 » Thu May 23, 2013 2:53 pm

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: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: Repeating last command from trigger.

Post by Jor'Mox » Thu May 23, 2013 3:04 pm

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 » Thu May 23, 2013 5:30 pm

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: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: Repeating last command from trigger.

Post by Jor'Mox » Thu May 23, 2013 5:49 pm

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 » Thu May 23, 2013 5:56 pm

That work!

Thank you!

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

Re: Repeating last command from trigger.

Post by keresZ » Thu May 23, 2013 6:39 pm

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

Who is online

Users browsing this forum: No registered users and 3 guests