Jump to content

MUDLET: Targeting, target highlighting, and targeted aliases


myrek

Recommended Posts

This post has 4 parts that show how to use Mudlet to create aliases - targeted, untargeted, and on-the-fly targets.

Part 1: the targeting alias
Part 2: the target highlighting trigger
Part 3: general spell alias template
Part 4: targeted spell alias

----------

PART 1: alias to set the target

CREATE ALIAS

Name: set target

Pattern:

^target (.+)$

Command: <leave blank>

Lua code:

target = matches[2]
cecho("<light_slate_blue>My target is now: <red>"..target.."\n")

Click "Save Item".

Explanation: this does nothing expect set the variable used for targeting. The cecho is used to show that the script functioned.

NOTE: You need to set a target before adding the trigger or targeted spell alias. If not, you may get an error.

----------

PART 2: highlighting

This actually has 2 parts. You have to create a Trigger and a Script.

CREATE TRIGGER

Name: target name

In the 1st field, add "highlightTarget()" w/o quotes. In the dropdown, select "lua function".

Click "Save Item".

CREATE SCRIPT

Name: target highlight

Lua script:

function highlightTarget()
  if target_high then killTrigger(target_high) end
  if target_low then killTrigger(target_low) end
  
	target_low = tempTrigger(target:lower(), [[selectString("]] .. target:lower() .. [[", 1) fg("red") resetFormat()]])
	target_high = tempTrigger((target:lower()):title(), [[selectString("]] .. (target:lower()):title() .. [[", 1) fg("red") resetFormat()]])
 
end

Click "Save Item".

Note: As is, the script makes the target red. If you want to change it, simply change "red" to any mudlet color.

----------

Part 3: General spell alias template (it will work for more than spells)

Name: faerie fire

Pattern:

^ff(.*)

Lua Code:

send("cast 'faerie fire'"..matches[2])

Click "Save Item".

Potential issues: If you have multiple aliases and the wrong alias is being triggered, you need to adjust your patterns. The key is using unique patterns.

Explanation: 
Pattern: The "^" tells it to match the beginning of the line. You can change the letters to suit your purposes. The "(.*)" grabs anything after the pattern's letters to use as a match.
Code: "Send" sends the text to the game (vs echo that only sends it to the screen.) It sends whatever is in the (). All you should need to adjust is what's in the single quotes.

Usage: 

"ff" will send "cast 'faerie fire'" without the double quotes.
"ff asdf" will send "cast 'faerie fire' asdf" without the double quotes. "matches[2]" takes care of everything after the pattern's letters including spaces

----------

Part 4: targeted spell alias

CREATE ALIAS

Name: faerie fire t

Pattern:

^tff$

Lua Code:

send("send 'faerie fire' "..target)

Click "Save Item".

Same potential issues as any alias. 

Usage: 

"tff" (if target is set to "bob") will send "cast 'faerie fire' bob" without the double quotes.

----------

That's the basics. You should be able to do a lot with these scripts. If you have any issues, let me know.

Link to comment
Share on other sites

×
×
  • Create New...