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
➜ Counting logs
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Cedron
(5 posts) Bio
|
Date
| Thu 07 Aug 2014 04:36 PM (UTC) |
Message
| I am in a room full of logs, some marked by their owners, some not. How would I go about counting and keeping a running total for each woodworker? In my limited mind, I'm guessing I'll need to make a trigger for each different persons name and another catch all for those lumber logs not named.
Here is an excerpt with one person and what the generic would be.
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(186).
A dusky ironwood log is stacked on a pallet, ready for shipping (187).
A dusky ironwood log is stacked on a pallet, ready for shipping (188).
A dusky ironwood log is stacked on a pallet, ready for shipping (189).
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(190).
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(191).
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(192).
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(193).
A dusky ironwood log is stacked on a pallet, ready for shipping, marked
with the image of a forest of tiny trees surrounded by a circle ("Ceras")
(194).
The number in the parenthesis is a running total of each log in the room. Given this many logs, its not something you want to tally yourself.
Thanks guys. | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #1 on Thu 07 Aug 2014 07:28 PM (UTC) |
Message
| The most obvious solution to me would be a regex trigger to highlight the stacks that don't have an owner. Provided of course all of the claimed ones don't have "shipping (#)" at the end of the line. Another option would be to have the regex kick the unclaimed ones to a text window rather than highlighting inline. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 07 Aug 2014 08:39 PM (UTC) Amended on Thu 07 Aug 2014 08:40 PM (UTC) by Nick Gammon
|
Message
| This should do it. Use 3 triggers, one for each line. The second two are initially disabled.
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="^A dusky ironwood log is stacked on a pallet, ready for shipping(, marked| \((?'count'\d+)\)\.)$"
name="log_trigger_1"
regexp="y"
send_to="12"
sequence="100"
>
<send>
count = tonumber ('%<count>')
-- make sure global variables exist
unowned = unowned or 0
owners = owners or {}
if count then
unowned = unowned + count
print ("Total unowned =", unowned)
else
EnableTrigger ("log_trigger_2", true)
end -- if
</send>
</trigger>
<trigger
custom_colour="2"
match="^with the image of a forest of tiny trees surrounded by a circle \("(?'owner'[^"]+)"\)$"
name="log_trigger_2"
regexp="y"
send_to="12"
sequence="100"
>
<send>
-- remember owner
current_owner = '%<owner>'
EnableTrigger ("log_trigger_2", false)
EnableTrigger ("log_trigger_3", true)
</send>
</trigger>
<trigger
custom_colour="2"
match="^\((?'count'\d+)\)\.$"
name="log_trigger_3"
regexp="y"
send_to="12"
sequence="100"
>
<send>
owners [current_owner] = owners [current_owner] or 0
owners [current_owner] = owners [current_owner] + tonumber ('%<count>')
EnableTrigger ("log_trigger_3", false)
require "tprint"
tprint (owners)
</send>
</trigger>
</triggers>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
This assumes your output wraps the way you showed. If not, you may have to fiddle around a bit.
The first trigger counts the unowned logs (since that line has a count on it). If not, it enables the second trigger.
The second trigger captures the owner's name and remembers it. It then disables itself and enables the third trigger.
The third trigger captures the count of the owned logs, and then disables itself.
The first and third triggers report the running totals. You may want to change how that is done, and have some mechanism for resetting the totals.
eg. To reset them all (like, when you first enter this room):
|
- 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.
13,924 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top