Mudlet Targeting System

September 28, 2015 07:53PM
A while back, a request was made for a targeting system for use with the Mudlet client. I would like to present mine. Thanks go to starbright for providing a Mudlet-ready one-target system, and to Kstatida for providing a multi-target system for JMC; their ideas inspired the system that follows. Since the afore-mentioned thread is several weeks old now, I am creating a new thread.

At its most basic, the system consists of one alias to set targets, one to swap targets, and, of course, one to murder targets. First, the setting mechanism:

Alias name: set_targets
Pattern: ^tt(.*) (.*)$

i = matches[2]
n = tonumber(matches[2])
v = matches[3]
print("----------------------------------------------------------------")
if i ~= "" and i ~= "0" and i ~= "1" and i ~= "2" and i ~= "3" and i ~= "4" and i ~= "5" and i ~= "6" and i ~= "7" and i ~= "8" and i ~= "9" then
print("tt<N> <target>")
print(" <target> : Name of target to store.")
print(" <N> : Optional. Specifies target index.")
print(" 0 : Primary target. Default if omitted.")
print(" 1-9: Reserve target 1-9.")
print("----------------------------------------------------------------")
print("Invalid syntax. Primary and reserve target(s) unchanged.")
print("----------------------------------------------------------------")
else
if n == nil or n == 0 then target[0] = v
else
target[n] = v
print(" Reserve target #"..i.." :", target[n])
print("----------------------------------------------------------------")
end
end
print(" Primary target :", target[0])
print("----------------------------------------------------------------")
i = nil
n = nil
v = nil

This alias uses an indexed variable named "target" to store up to 10 targets. Usage is:

tt<n> <target>

Where <n> is the index to use, and <target> is the name to store. If <n> equals 0 or is omitted, index 0 is used, which specifies the primary target. If <n> equals 1 through 9 inclusive, index 1-9 is used, which specifies reserve target 1-9. If <n> is anything other than 0-9, an error message is printed, and all target(s) will be unchanged. The current primary target will always be displayed. Reserve target(s) will be displayed only if they are changed.

Next, the swapping mechanism:

Alias name: change_targets
Pattern: ^ct(.*)$

i = matches[2]
n = tonumber(matches[2])
print("----------------------------------------------------------------")
if i ~= "1" and i ~= "2" and i ~= "3" and i ~= "4" and i ~= "5" and i ~= "6" and i ~= "7" and i ~= "8" and i ~= "9" then
print("ct<N>")
print(" <N> : Index of target (1-9) to swap with primary target.")
print("----------------------------------------------------------------")
print("Invalid syntax. Primary and reserve target(s) unchanged.")
else
target[n], target[0] = target[0], target[n]
print(" Reserve target #"..i.." ---> Primary target")
print("----------------------------------------------------------------")
if target[n] == "" then
print(" Reserve target #"..i.." :", "<not defined>")
else
print(" Reserve target #"..i.." :", target[n])
end
end
print("----------------------------------------------------------------")
if target[0] == "" then
print(" Primary target :", "<not defined>")
else
print(" Primary target :", target[0])
end
print("----------------------------------------------------------------")
i = nil
n = nil

This alias swaps targets stored in indexes 1-9 with the primary target stored in index 0. Usage is:

ct<n>

Where <n> is the index to swap with index 0. If <n> does not equal 1-9, an error message is displayed, all target(s) will be unchanged, and the value of index 0 will be displayed. Otherwise, index <n> will be swapped with index 0, and the current values of both indexes will be displayed.

Finally, the murdering mechanism:

Alias name: murder_target
Pattern: ^mt\s*(.*)$

v = matches[2]
n = tonumber(matches[2])
if v ~= "" and v ~= "0" and v ~= "1" and v ~= "2" and v ~= "3" and v ~= "4" and v ~= "5" and v ~= "6" and v ~= "7" and v ~= "8" and v ~= "9" then
send("murder "..v)
else
if n == nil or n == 0 then send("murder "..target[0])
else send("murder "..target[n])
end
end

This alias sends a murder command. Usage is:

mt<optional space><target>

Where <target> can be either the index of a predefined target or another value. If <target> equals 0 or is omitted, index 0, the primary target, is used. If <target> equals 1-9, the appropriate index for a reserve target is used. If <target> is any other value, that value is used.

If properly configured, when using these aliases, you should see output very similar to this:

> tt Bob --OR-- tt0 Bob
----------------------------------------------------------------
Primary target : Bob
----------------------------------------------------------------

> tt1 Earl
----------------------------------------------------------------
Reserve target #1 : Earl
----------------------------------------------------------------
Primary target : Bob
----------------------------------------------------------------

> tt<n> Frank
----------------------------------------------------------------
Reserve target #n : Frank
----------------------------------------------------------------
Primary target : Bob
----------------------------------------------------------------

> ct1
----------------------------------------------------------------
Reserve target #1 ---> Primary target
----------------------------------------------------------------
Reserve target #1 : Bob
----------------------------------------------------------------
Primary target : Earl
----------------------------------------------------------------

> mt --OR-- mt0 --OR-- mt 0
murder Earl

> mt1 --OR-- mt 1
murder Bob

> mtCletus --OR-- mt Cletus
murder Cletus

The murdering mechanism can be very easily adapted for use with any command that requires a target. Here's an example that uses the dirt kicking command:

Alias name: dirt_target
Pattern: ^dt\s*(.*)$

v = matches[2]
n = tonumber(matches[2])
if v ~= "" and v ~= "0" and v ~= "1" and v ~= "2" and v ~= "3" and v ~= "4" and v ~= "5" and v ~= "6" and v ~= "7" and v ~= "8" and v ~= "9" then
send("dirt "..v)
else
if n == nil or n == 0 then send("dirt "..target[0])
else send("dirt "..target[n])
end
end

Comments and questions are welcome.
Subject Author Posted

Mudlet Targeting System

zzragnarokzz September 28, 2015 07:53PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 46
Record Number of Users: 59 October 25, 2015
Record Number of Guests: 341 February 12, 2018