Im playing on a mud and my job as part of a pkill group will be to scan for enemy players and report thier number direction and distance. I dont have a lot of skill with scripting variables and tables or plugins, i mostly use simple point and click interface or scripting some DoAfters, using lua.
You scan all six directions around you:
+* A Skaven *+ is a long ways off south from here.
+* A Troll *+, +* A Skaven *+, +* An Ogre *+ and a dwarven elite guard are immediately east from here.
+* A Human *+ is pretty close by west from here.
that scan would need to return:
gt CONTACT:: 1 Enemy 3 South
gt CONTACT:: 3 Enemy 1 East
gt CONTACT:: 1 Enemy 2 West
Additionally, if i need to target the troll specificly, it could return:
gt CONTACT:: 1 Enemy 3 South
gt CONTACT:: 3 Enemy 1 East Target: Troll
gt CONTACT:: 1 Enemy 2 West
I would really appreciate any help with this anyone can give me.
After looking around a bit, I've decided to first put the scan data into it's own window using the chat re-director. It seems to be up and running and sending scan info to the new window, however the scans all pile up on each other and they are difficult to sort out. My attempt to insert a trigger is not working.
<trigger
enabled="y"
match="^You scan all six directions around you"
omit_from_output="y"
regexp="y"
sequence="90"
>
<send>
local scan = GetWorld ("scan")
scan:DeleteOutput()
</send>
</trigger>
I also tried this as a trigger to scan:Execute("cls") a working cls alias i had set up on the scan world, to no effect.
got the scan window up and working, and it refreshes on each scan, i have world triggers on each world that access the scan plugin to call out direction and distance properly. where im falling down is how to get it to count and display the count of enemies in a given direction and distance.
i think my main problem is not knowing what the functions i need are called in order to look them up and find examples i can use to finish this off.
Sorry, for the lack of clarity, that's based on not really being sure what's relevant and what isn't. This is a copy of the trigger group I'm using to call direction and range of the contacts.
<triggers>
<trigger
enabled="y"
group="radar"
match="You scan all six directions around you"
name="clearscan"
omit_from_log="y"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="30"
>
<send>local W = GetWorld ("scan")
W:DeleteOutput ()</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="\*\+(.*?) (is|are) a long ways off (.*.) from here"
name="threerooms"
regexp="y"
send_to="12"
sequence="40"
>
<send>DoAfter (.1, "gt Enemy Contact: 3 %3")</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="\*\+(.*?) (is|are) immediately (.*.) from here"
name="oneroom"
regexp="y"
send_to="12"
sequence="40"
>
<send>DoAfter (.1, "gt Enemy Contact: 1 %3")
</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="\*\+(.*?) (is|are) pretty close by (.*.) from here"
name="tworooms"
regexp="y"
send_to="12"
sequence="40"
>
<send>DoAfter (.1, "gt Enemy Contact: 2 %3")</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="\*\+(.*?) (is|are) very distant to the (.*.) from here"
name="fourrooms"
regexp="y"
send_to="12"
sequence="40"
>
<send>DoAfter (.1, "gt Enemy Contact: 4 %3")</send>
</trigger>
</triggers>
The following scan
+* A Troll *+, +* A Skaven *+, +* An Ogre *+ and a dwarven elite guard are immediately east from here.
Returns
Enemy Contact: 1 east
What i am looking for it to do is count up the number of matches on *+ for each incoming line and be able to return
+* A Drow *+, +* An Illithid *+ and +* An Ogre *+ are immediately west from here.
+* A Drow *+, a male kobold warrior and a kobold female are immediately east from here.
There may be from 1 to lets say 10 contacts in one pk group.
--When i use this to match it seems to work.
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="(.*?) (is|are) immediately (.*.) from here"
name="oneroom"
regexp="y"
send_to="12"
sequence="40"
>
<send>
local whatever, count
if string.find ("%1", "%*%+") then
whatever, count = string.gsub ("%1", "%*%+", "xxx")
count = count + 1 -- final one doesn't end in comma, plus the "and xxx"
else
count = 0
end -- if
DoAfter (.1, "gt Enemy Contact: " .. count-1 .. " enemy 1 %3")
</send>
</trigger>
</triggers>
-- However now it calls out all non enemy player mobs as -1 enemy. sigh. though if an enemy is present in the same room it does call everything correctly.
An apprentice swashbuckler is a long ways off west from here.
-- returns
You tell the group 'Enemy Contact: -1 enemy 3 west'
An azer knight and Guunk, the atomie are pretty close by north from here.
-- returns
You tell the group 'Enemy Contact: -1 enemy 2 north'
Defile, Violate and Outrage are immediately east from here.
-- returns
You tell the group 'Enemy Contact: -1 enemy 1 east'
A dwarven elite guard, a dwarven elite guard, a dwarven elite guard and a dwarven elite guard are a long ways off east from here.
-- returns
You tell the group 'Enemy Contact: -1 enemy 3 east'
-- however if an enemy is present it calls correctly no matter the number of enemy, distance or direction.
+* A Skaven *+ is pretty close by south from here.
-- returns
You tell the group 'Enemy Contact: 1 enemy 2 south'
+* A Skaven *+, +* An Ogre *+ and a kobold are immediately north from here.
-- returns
You tell the group 'Enemy Contact: 2 enemy 1 north'
+* A Troll *+, +* A Skaven *+, +* An Ogre *+ and a dwarven elite guard are immediately east from here.
-- returns
You tell the group 'Enemy Contact: 3 enemy 1 east'
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="(?P<who>.*?) (is|are) (?P<howfar>a long ways off|immediately|pretty close by|very distant to the) (?P<where>.*.) from here"
name="oneroom"
regexp="y"
send_to="12"
sequence="40"
>
<send>
local whatever, count, count1, count2
-- count the "and"s
whatever, count1 = string.gsub ("%<who>", " and ", "")
-- count the commas
whatever, count2 = string.gsub ("%<who>", ",", "")
count = 1 + count1 + count2 -- there will always be one
DoAfter (0.1, "gt Enemy Contact: " .. count .. " %<where> (%<howfar>)")
</send>
</trigger>
</triggers>
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
That gives me:
gt Enemy Contact: 1 west (a long ways off)
gt Enemy Contact: 3 north (pretty close by)
gt Enemy Contact: 3 east (immediately)
gt Enemy Contact: 4 east (a long ways off)
I only want to count the enemy players which are marked like +* A Drow *+ or +* An Ogre *+ and ignore all the regular mobs which do not have +* *+ around them. this is the bit im having trouble with. That must have been one of the things i was vague about before.
also, i have 4 triggers in the set, one for each distance, immediate, close by, a long ways off, and very distant, so i can have it say 1 west 2 west 3 west instead of the words. though that part is easy to fix.
the following trigger as one of 4 in the set works perfectly on calling correct numbers of enemy players and separating out enemy players from regular mobs in the same room as the enemy players. It however also calls out common non enemy mobs when no enemy players are present, but as they are not enemy it doesnt count them, basicly saying, their is something which is not an enemy over there. As regular mobs are unimportant i do not want them called out at all. the purpose is to call enemies only to my group. i can see the regular mobs and enemy players in my scan window for myself.
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="radar"
match="(.*?) (is|are) immediately (.*.) from here"
name="oneroom"
regexp="y"
send_to="12"
sequence="40"
>
<send>
local whatever, count
if string.find ("%1", "%*%+") then
whatever, count = string.gsub ("%1", "%*%+", "xxx")
count = count + 1 -- final one doesn't end in comma, plus the "and xxx"
else
count = 0
end -- if
An apprentice swashbuckler is a long ways off west from here.
An azer knight and Guunk, the atomie are pretty close by north from here.
Defile, Violate and Outrage are immediately east from here.
A dwarven elite guard, a dwarven elite guard, a dwarven elite guard and a dwarven elite guard are a long ways off east from here.
+* A Skaven *+ is pretty close by south from here.
+* A Skaven *+, +* An Ogre *+ and a kobold are immediately north from here.
+* A Troll *+, +* A Skaven *+, +* An Ogre *+ and a dwarven elite guard are immediately east from here.
Result:
gt Enemy Contact: 1 south (pretty close by)
gt Enemy Contact: 2 north (immediately)
gt Enemy Contact: 3 east (immediately)
i do believe that's got it working. i ran a few various tests on it and it seems to be doing exactly what i need it to. thank you so much for the help nick, your awesome.