Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ help with radar.
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Wed 31 Jul 2013 04:48 PM (UTC) Amended on Mon 26 Aug 2013 10:39 AM (UTC) by AzurDrake
|
| Message
| hi,
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.
AZ | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Wed 31 Jul 2013 11:03 PM (UTC) |
| Message
| |
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #2 on Thu 01 Aug 2013 03:06 AM (UTC) |
| Message
| Hi Nick,
Thank you for the quick response.
AZ | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #3 on Sun 04 Aug 2013 09:05 PM (UTC) Amended on Sun 04 Aug 2013 09:21 PM (UTC) by AzurDrake
|
| Message
| Ok,
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. | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #4 on Tue 20 Aug 2013 08:40 PM (UTC) |
| Message
| okay,
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.
meanwhile it's half working. thanks for the help.
AZ | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Tue 20 Aug 2013 10:44 PM (UTC) |
| Message
| That's fairly vague.
You count by adding one, eg.
For a "given direction" you would set the count to zero and then start counting. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #6 on Fri 23 Aug 2013 08:03 PM (UTC) Amended on Mon 26 Aug 2013 10:40 AM (UTC) by AzurDrake
|
| Message
| 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
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
Enemy Contact: 3 enemy 1 east
[EDIT] Code tags added.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #7 on Fri 23 Aug 2013 11:20 PM (UTC) |
| Message
| Something like this:
<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", "[^,],", "xx")
count = count + 2 -- final one doesn't end in comma, plus the "and xxx"
else
count = 1
end -- if
DoAfter (.1, "gt Enemy Contact: " .. count .. " %3")
</send>
</trigger>
</triggers>
For the matching string it counts the number of groups ending with a comma (maybe counting commas would have been enough?).
Then add two.
eg.
Fred, Jane, Bob and Nick are 2 east of here.
Two commas, four mobs. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #8 on Sat 24 Aug 2013 02:27 AM (UTC) Amended on Mon 26 Aug 2013 01:41 PM (UTC) by AzurDrake
|
| Message
| Apologies,
+* 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. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #9 on Sat 24 Aug 2013 07:10 AM (UTC) |
| Message
| How about posting sample output for one mob, two mobs, three mobs and four mobs?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #10 on Sat 24 Aug 2013 07:15 AM (UTC) Amended on Mon 26 Aug 2013 10:41 AM (UTC) by AzurDrake
|
| Message
| 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'
| | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #11 on Sat 24 Aug 2013 07:50 AM (UTC) |
| Message
| if their are no enemy present i want it to just be quiet, so something like if count-1 is less than 1 do nothing
just not sure how to implement that. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #12 on Sun 25 Aug 2013 01:37 AM (UTC) Amended on Sun 25 Aug 2013 01:38 AM (UTC) by Nick Gammon
|
| Message
| How about:
<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)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| AzurDrake
(11 posts) Bio
|
| Date
| Reply #13 on Mon 26 Aug 2013 11:41 AM (UTC) Amended on Mon 26 Aug 2013 01:39 PM (UTC) by AzurDrake
|
| Message
| hrmm,
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
DoAfter (.1, "gt Enemy Contact: " .. count-1 .. " enemy 1 %3")
</send>
</trigger>
</triggers>
Thank you so much for your valuable time. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #14 on Tue 27 Aug 2013 05:13 AM (UTC) |
| Message
| Well that makes it easier, if anything:
<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
-- count the wanted mobs
whatever, count = string.gsub ("%<who>", "%%+%%*.-%%*%%+", "")
if count > 0 then
DoAfter (0.1, "gt Enemy Contact: " .. count .. " %<where> (%<howfar>)")
end -- if
</send>
</trigger>
</triggers>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
You have to double the % signs inside the regular expression because MUSHclient interprets %x as meaning something unless it is %%x. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
62,322 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top