About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chris123zugg
Adept


Joined: 23 Aug 2013
Posts: 207

PostPosted: Sun Mar 16, 2025 4:57 pm   

creating a new database part7 XD
 
sooo hi there again everyone, im attempting to create a trigger that makes a database of who tapped me, and counts the times they tapped me
Then i can use this as a pure information and at a breakpoint of like 50 ill do something else....


Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="party tap" priority="52720" copy="yes">
    <pattern>(%w) taps you on the shoulder.</pattern>
    <value>#var timtetaps
#if (timetaps > 0 &amp;&amp; %ismember(%1, @taps)) {#show @taps}
#var taps %additem(%1,@taps)
#if (%ismember(%1, @taps)) {#print works for record %1 is alread in the record!} {#addkey taps name "%1"}
coffinn = (@coffinn -1)
unwrap;emote has %ansi(14)Coffin: @coffinn/@coffinnm Freezer: @freezer/25 left.%ansi(reset)</value>
  </trigger>
</cmud>



this is the "start" i can get it to record the name of someone, but cannot for the life of me get the value to work for the person.

some help would be needed and again, much appreciated! (especially you shalimar :P)

(Shalimar edited to fix the code tags)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4734
Location: Pensacola, FL, USA

PostPosted: Sun Mar 16, 2025 6:46 pm   
 
$name=%1
$count=%db(timeTaps, $name)
$count=($count+1)
#ADDKEY timeTaps $name $count


then you can reference any given person with @timeTaps.name
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4734
Location: Pensacola, FL, USA

PostPosted: Sun Mar 16, 2025 7:14 pm   
 
If you are looking to only allow certain names to work, you can whitelist it via the pattern instead of checking after the fact

#TR {({name1|name2|name3}) taps you on the shoulder.} {stuff}
#TR {({@tappersClub}) taps you on the shoulder.} {stuff}
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Adept


Joined: 23 Aug 2013
Posts: 207

PostPosted: Sun Mar 16, 2025 7:29 pm   
 
you are the man shalimar:P
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4734
Location: Pensacola, FL, USA

PostPosted: Sun Mar 16, 2025 7:32 pm   
 
Though depending on how much info you plan on keeping about people, you might wanna nest it better:

$name=%1
$this=%db(@charData, $name)
$count=%db($this, "timesTapped")
$count=($count+1)
#ADDKEY $this timesTapped $count
#ADDKEY charData $name $this
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4734
Location: Pensacola, FL, USA

PostPosted: Sun Mar 16, 2025 7:57 pm   
 
as for how to best phrase the break points:

Code:
#SWITCH ($count<50) {this}
  ($count<100) {that}
  ($count<200) {hey now}
  {someone is an overachiever}


This works because a switch only performs for the first condition it meets, so the order of the conditions matters. The overflow is optional.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Adept


Joined: 23 Aug 2013
Posts: 207

PostPosted: Sun Mar 16, 2025 7:59 pm   
 
nice, im gonna use this :) thanks again!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net