In the mud I play(which is a pk mud) acting first and acting accordingly can sometimes decide the outcome of who wins and who loses, as a big battle only lasts 40-90 seconds. so!
Example:
Bob walks in from the west
Steve walks in from the west
Cleric walks in from the west
Julian walks in from the west
24321H 2123V...
--
Now, what I want to do is examine the names here and do an action on a name with a predefined priority to handle which name gets an action. In other words, I'd have all these names in a pk_list table so that if:
Bob walks in from the west -- kill bob
Bob walks in from the west
Cleric walks in from the west -- kill cleric
--
So, pk_list = {"Bob", "Cleric", "Steve", "Julian", "Susan", "Tiffany"}
--
Enable a trigger to match: (\w+) walks in from the west$
pk_check = {} -- create empty table or erase values if table exists already
for i,v in ipairs(pk_list) do
if v == "%1" then
EnableTrigger("pk_check_start", true)
EnableTrigger("pk_check_stop", true)
EnableTrigger("This_Trigger", false) -- so it stops matching (\w+) walks in from the west$
table.insert(pk_check, %1) -- to put the name that started the trigger into the table.
end end
--
pk_check_start trigger would match: *
table.insert(pk_check, "%0") -- adds to pk_check table everything coming from the mud.
pk_check_stop trigger would match: ^(\d+)H|^$
EnableTrigger("pk_check_start", false)
EnableTrigger("pk_check_stop", false)
for i,v in ipairs(pk_check) do
print(i,v) end
--
So on print(i,v) in table pk_check I'd have:
1 Bob
2 Steve walks in from the west
3 Cleric walks in from the west
4 Julian walks in from the west
--
I've got all the names I wanted to capture into the table, but at this point I'm not sure what to do to have certain names predefined to take the action first over other names. And also I would have to extract the names I want from the strings, so I'd probably create another table from that and get a table full of just names(if i even need to do that).
I'd appreciate any thoughts/suggestions.
Thanks!!
Example:
Bob walks in from the west
Steve walks in from the west
Cleric walks in from the west
Julian walks in from the west
24321H 2123V...
--
Now, what I want to do is examine the names here and do an action on a name with a predefined priority to handle which name gets an action. In other words, I'd have all these names in a pk_list table so that if:
Bob walks in from the west -- kill bob
Bob walks in from the west
Cleric walks in from the west -- kill cleric
--
So, pk_list = {"Bob", "Cleric", "Steve", "Julian", "Susan", "Tiffany"}
--
Enable a trigger to match: (\w+) walks in from the west$
pk_check = {} -- create empty table or erase values if table exists already
for i,v in ipairs(pk_list) do
if v == "%1" then
EnableTrigger("pk_check_start", true)
EnableTrigger("pk_check_stop", true)
EnableTrigger("This_Trigger", false) -- so it stops matching (\w+) walks in from the west$
table.insert(pk_check, %1) -- to put the name that started the trigger into the table.
end end
--
pk_check_start trigger would match: *
table.insert(pk_check, "%0") -- adds to pk_check table everything coming from the mud.
pk_check_stop trigger would match: ^(\d+)H|^$
EnableTrigger("pk_check_start", false)
EnableTrigger("pk_check_stop", false)
for i,v in ipairs(pk_check) do
print(i,v) end
--
So on print(i,v) in table pk_check I'd have:
1 Bob
2 Steve walks in from the west
3 Cleric walks in from the west
4 Julian walks in from the west
--
I've got all the names I wanted to capture into the table, but at this point I'm not sure what to do to have certain names predefined to take the action first over other names. And also I would have to extract the names I want from the strings, so I'd probably create another table from that and get a table full of just names(if i even need to do that).
I'd appreciate any thoughts/suggestions.
Thanks!!