Creating Alias with Trigger condition.

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

Creating Alias with Trigger condition.

Post by valvido » Tue Apr 23, 2013 8:21 am


Is it possible to make a Alias that has a IF nested Trigger within?

I want to set up crafting Alias with 2 commands. If the first command fail (crafting did not succeed), then a IF trigger will invoke and repeat the first command. If it did not fail, then the second part of the Alias will fire.

Alias: "brew deadly" will do

Code: Select all

get bag backpack
get deadly bag
brew deadly
IF brew is successful, the MUD will give this output:

Code: Select all

You make a blue-violet liquid out of a deadly nightshade.
I want Mudlet to then do this when it see that the brew is succesfull

Code: Select all

put bag backpack
quaff vial
But if it isn't successful, then I want it to attempt another brew by sending in

Code: Select all

brew deadly
This would be easy if I knew the LUA code to use within the IF statement.

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

Re: Creating Alias with Trigger condition.

Post by Jor'Mox » Tue Apr 23, 2013 8:51 pm

Well, you need to make two temporary triggers, one for success, one for failure. It could look something like this:
Code: [show] | [select all] lua
if id1 then killTrigger(id1) end
id1 = tempTrigger("You make a blue-violet liquid out of a deadly nightshade.", [[send("put bag backpack") send("quaff vial") killTrigger(id1) killTrigger(id2)]])
if id2 then killTrigger(id2)
id2 = tempTrigger("I FAILED BREWING", [[send("brew deadly") killTrigger(id1) killTrigger(id2)]])
Basically, you make a trigger for each condition, include the commands you need to send, and then kill both triggers whenever either of them happens. If you don't have a reliable triggering string for failure, you could use a tempTimer instead of the second trigger, and just have it wait a few seconds and then go ahead as if you failed. Like this:
Code: [show] | [select all] lua
tempTimer(2,[[send("brew deadly") killTrigger(id1)]])

Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm

Re: Creating Alias with Trigger condition.

Post by Delrayne » Tue Apr 23, 2013 10:46 pm

Um, you could just trigger the success and fail lines

On success:
Code: [show] | [select all] lua
send("put bag backpack")
send("quaff vial")
On failure:
Code: [show] | [select all] lua
expandAlias("brew deadly")
--This assumes you have the alias brew deadly made like you mentioned

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests