Page 1 of 1

Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 9:11 am
by Elysia
Essentially, clan coffers are tied to room in much the same way rents are. This is an example of the output of a clan coffer:

* I100 R:12345 S:Inside HP:Healthy SP:Bursting MV:Fresh > /note 12345coffer
1. a treasurer (50) Tue Sep 11 2018
Bobby deposited 1000
2. a treasurer (50) Wed Sep 12 2018
Bobby deposited 1000
3. a treasurer (50) Wed Sep 12 2018
Bobby deposited 1000
4. a treasurer (50) Tue Sep 18 2018
Sally deposited 1000
5. a treasurer (50) Tue Sep 18 2018
Sally deposited 1000
6. a treasurer (50) Tue Sep 18 2018
Bobby deposited 1000
7. a treasurer (50) Sat Oct 06 2018
Bobby deposited 1000
8. a treasurer (50) Sat Oct 06 2018
Bobby deposited 1000

Word of warning, I'm not good with CMUD scripting, I'm impressed I got this far to start with:

#CLASS CofferTally
#ALIAS {tallyrn} {~/note %1coffer}
#TRIGGER {deposited 1000} {#ADD %1coffer 1000}
#TRIGGER {deposited 100} {#ADD %1coffer 100}
#CLASS 0

It essentially lets me type "tallyrn 12345" and it will spit out the corresponding coffer transactions. CMUD to triggers on "deposited 1000" or "deposited 100" and add accordingly. I can then make it spit out the tally if I type #VAR 12345coffer. It would be more helpful though if the script itself either:

-#ECHO or #SHOW or #SAY or whatever the total tally is (instead of me having to type #VAR 12345coffer
or
-write it to the same note, which in this case would be /note 12345coffer jot #

I'd also have to add the corresponding triggers for withdrawls and rare depositing, but that I can manage. It's getting it to show output for the math result that is befuddling me.

Any CMUD wizards out there?

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 10:51 am
by Taziar
Try this... triggers output off of the next prompt received from the mud.

Code: Select all

#CLASS {CofferTally}
#ALIAS tallyrn {
   #T+ {CofferTally|CofferTriggers}
   #VAR cofferTotal {}
   #VAR cofferNames {}
   #VAR cofferNameAmounts {}
   #SEND {~/note %concat(%parms,coffer)}
   }
#VAR cofferTotal {}
#VAR cofferNames {}
#VAR cofferNameAmounts {}
#VAR cofferNameTotal {}
#CLASS 0
#CLASS {CofferTally|CofferTriggers} {disable}
#TRIGGER "cofferGoldCrowns" {^([A-Z]%w) deposited (%d)} {
   #ADDITEM cofferNames %1
   #VAR cofferNameAmounts %additem(%concat(%1,%2),@cofferNameAmounts)
   #ADD cofferTotal %2
   } "" {case}
#TRIGGER "cofferPrompt" {^{o|*} * > } {
   #T- {CofferTally|CofferTriggers}
   #PRINT {%crlf}
   #FORALL @cofferNames {
      #VAR cofferNameTotal {}
      #FORALL @cofferNameAmounts {
         #IF (%begins(%j,%1)) {
            #ADD cofferNameTotal %remove(%i,%j)
            } {}
         }
      #PRINT { %i deposit total: @cofferNameTotal}
      }
   #PRINT {%crlf Total Gold Crowns: @cofferTotal}
   } "" {nocr|prompt}
#CLASS 0


1. a treasurer (50) Tue Sep 11 2018
Bobby deposited 1000
2. a treasurer (50) Wed Sep 12 2018
Bobby deposited 1000
3. a treasurer (50) Wed Sep 12 2018
Bobby deposited 1000
4. a treasurer (50) Tue Sep 18 2018
Sally deposited 1000
5. a treasurer (50) Tue Sep 18 2018
Sally deposited 1000
6. a treasurer (50) Tue Sep 18 2018
Bobby deposited 1000
7. a treasurer (50) Sat Oct 06 2018
Bobby deposited 1000
8. a treasurer (50) Sat Oct 06 2018
Bobby deposited 1000
* insert prompt here >

Bobby deposit total: 6000
Sally deposit total: 2000

Total Gold Crowns: 8000


If it doesn't work I blame writing this before finishing my first cup of coffee :P

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 7:53 pm
by Elysia
Couldn't open notes/ZZZ/%parmscoffer with mode r

* R:12345 S:Inside HP:Healthy SP:Bursting MV:Fresh >


Total Gold Crowns:

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 8:54 pm
by Taziar
Looks like I typo'd the %params function.

Try...

Code: Select all

#SEND {~/note %concat(%params,coffer)}


In the changes from zMUD to cMUD section it says that each line should start with a zScript command and #ALIAS command should use the %params function to pass the text after the alias name... granted it looks like how you originally did it worked. So you could try to use...

Code: Select all

~/note %1coffer


instead of the #SEND line if the #SEND line doesn't work this time

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 9:36 pm
by Elysia
Both variaties just do this now:


* R:5798 S:Inside HP:Healthy SP:Bursting MV:Fresh >


Total Gold Crowns:

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 9:43 pm
by Taziar
Are the character names proper case like in the original example?

And is the note opening now?

Also, are there any spaces in front of the character name that got lost in the original example from forum formatting?

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Sun Oct 07, 2018 9:54 pm
by Taziar
I write my pattern matching in my triggers to be as exact as possible, not that you need that for this, but it is habit. So...

Code: Select all

^([A-Z]%w) deposited (%d)


The two sets of () denote %1 and %2
^ matches to the start of the line
[A-Z] matches a capital letter if the {case} option is set
%w matches a word
%d matches a number

can remove: ^ [A-Z] case
and it will still work

Code: Select all

(%w) deposited (%d)

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Mon Oct 08, 2018 9:27 am
by Elysia
That last thing worked! Thanks!

I think it actually goes -space- Name but if the simpler version works...

Re: Immortal request: a CMUD script for clan coffer tallying.

Posted: Mon Oct 08, 2018 9:30 am
by Elysia
Come to think of it, I might be able to make some mobol that will allow players to see the most recent tally that was done.