Immortal request: a CMUD script for clan coffer tallying.

... A place to ask for help on any topic whether it be starting out to player killing to IT issues.
Elysia
Posts: 4472
Joined: Sun Feb 15, 2015 1:29 pm

Immortal request: a CMUD script for clan coffer tallying.

Postby Elysia » Sun Oct 07, 2018 9:11 am

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?

Taziar
Posts: 514
Joined: Sat Mar 21, 2015 10:28 pm
Location: Seattle

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

Postby Taziar » Sun Oct 07, 2018 10:51 am

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

Elysia
Posts: 4472
Joined: Sun Feb 15, 2015 1:29 pm

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

Postby Elysia » Sun Oct 07, 2018 7:53 pm

Couldn't open notes/ZZZ/%parmscoffer with mode r

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


Total Gold Crowns:

Taziar
Posts: 514
Joined: Sat Mar 21, 2015 10:28 pm
Location: Seattle

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

Postby Taziar » Sun Oct 07, 2018 8:54 pm

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

Elysia
Posts: 4472
Joined: Sun Feb 15, 2015 1:29 pm

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

Postby Elysia » Sun Oct 07, 2018 9:36 pm

Both variaties just do this now:


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


Total Gold Crowns:

Taziar
Posts: 514
Joined: Sat Mar 21, 2015 10:28 pm
Location: Seattle

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

Postby Taziar » Sun Oct 07, 2018 9:43 pm

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?

Taziar
Posts: 514
Joined: Sat Mar 21, 2015 10:28 pm
Location: Seattle

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

Postby Taziar » Sun Oct 07, 2018 9:54 pm

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)

Elysia
Posts: 4472
Joined: Sun Feb 15, 2015 1:29 pm

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

Postby Elysia » Mon Oct 08, 2018 9:27 am

That last thing worked! Thanks!

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

Elysia
Posts: 4472
Joined: Sun Feb 15, 2015 1:29 pm

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

Postby Elysia » Mon Oct 08, 2018 9:30 am

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.


Return to “Help and Newbie Area”

Who is online

Users browsing this forum: No registered users and 2 guests