Triggering from variables?

Post Reply
sephiel
Posts: 17
Joined: Mon Nov 30, 2009 10:35 am

Triggering from variables?

Post by sephiel »

Hi guys, pretty new to scripting but loving the client. Everything runs so quickly, problems are being fixed constantly and although I'm new to all this, I can already tell how flexible my options are using this client. You guys should be proud of your work :)

So anyhow, just a quick query - is it possible to trigger something from a variable? I have a variable "target" and I'd like to configure it so when text matching that value is sent from the MUD, it gets highlighted. So if I'm targetting "goblin" and "A goblin hits you" gets sent, the word "goblin" can picked out and highlighted.

I dunno if it's possible with mudlet, or how to go about it if it is, just curious. Thanks in advance.

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

Re: Triggering from variables?

Post by Vadi »

screenshot_167.png
Hope that explains it all.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Triggering from variables?

Post by Heiko »

In your case Vadi's solution is certainly the best choice.

However, as this forum is intended as a general FAQ, I'll explain how to do real variable triggers.
If you want to trigger on the value of the variable "myVariable" you can make following trigger:

pattern:if myVariable == 17 then return true else return false end
pattern type: Lua condition
script: echo("the variable myVariable=" .. myVariable)

sephiel
Posts: 17
Joined: Mon Nov 30, 2009 10:35 am

Re: Triggering from variables?

Post by sephiel »

Awesome, thank you so much!

Metho
Posts: 14
Joined: Wed Sep 16, 2009 10:20 pm

Re: Triggering from variables?

Post by Metho »

What would cause this not to work? (Vadi's solution) I did exactly what was in the picture, and it doesn't highlight. Also, is there an ignore case function as well? Or could I perform something like string.lower on both matches[2] and target so that they'll match even if case isn't the same?

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

Re: Triggering from variables?

Post by Vadi »

tbh I wouldn't use that, as it's kinda slow. I've come up with a much better "Mudlet way" as described here:

http://dl.dropbox.com/u/84880/mudlet_do ... ing-howtos

(will be in online manual soon)

Metho
Posts: 14
Joined: Wed Sep 16, 2009 10:20 pm

Re: Triggering from variables?

Post by Metho »

Alright. Why do I want capitalize, though? I guess my issue was I'd want it to match either as Renegade or renegade.

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

Re: Triggering from variables?

Post by Vadi »

Capitalize for the players name. If you'd like to match on both, well then duplicate the 2 lines needed for that one trigger, make one for non-capital name first and another for capitalized.

Post Reply