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
talith
Novice


Joined: 03 Mar 2005
Posts: 31

PostPosted: Thu May 19, 2011 12:23 am   

stumped with trigger.
 
I'm trying to get a trigger working and while it does semi work, it's not working quite the way I want it to. This trigger fires anytime i look into a container. It counts the items inside, and displays them in a nice list. The problem is if there are multiples of an item, it will not increment the count of said item. For example when I look into a tool cabinet it might show something like:


It contains:
a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror, a silver mirror.

With the trigger active, it will instead display:


-------------------------------------------------------------------------------
1 silver mirror
-------------------------------------------------------------------------------

As you can see, it should be saying more than just 1 mirror. I've tried to figure out the problem but I'm stumped. Hopefully someone else can figure it out.




Code:
#CLASS {Container}
#VAR Contents {} {}
#VAR Hold_Contents {}
#TRIGGER {It contains:} {#GAG}
#COND {(*).} {
  #DBLOAD co
  #GAG 0
  #DBFIRST
  #WHILE (!%null( %rec)) {#DBDELETE &Num}
  #SHOW -------------------------------------------------------------------------------
  #VARIABLE Contents {%1} {_nodef} Container
  #VARIABLE Contents {%replace( @Container/Contents, ", ", "|")} {} Container
  #VARIABLE Hold_Contents {} {_nodef} Container
  #FORALL @Container/Contents {
    #VARIABLE Hold_Contents {%i} {_nodef} Container
    #IF (%word( @Hold_Contents, 1) = "a") {#VARIABLE Hold_Contents {%right( @Hold_Contents, 2)} {_nodef} Container}
    #IF (%word( @Hold_Contents, 1) = "A") {#VARIABLE Hold_Contents {%right( @Hold_Contents, 2)} {_nodef} Container}
    #IF (%word( @Hold_Contents, 1) = "an") {#VARIABLE Hold_Contents {%right( @Hold_Contents, 3)} {_nodef} Container}
    #IF (%word( @Hold_Contents, 1) = "An") {#VARIABLE Hold_Contents {%right( @Hold_Contents, 3)} {_nodef} Container}
    #IF (%isnumber( %word( @Hold_Contents, 1))) {#NEW cobycount object=%right( %replace( @Hold_Contents, %word( @Hold_Contents, 1), ''), 1) count=%word( @Hold_Contents, 1)} {#IF (%query( &Object = @Hold_Contents)) {#DBGET %query( &Object = @Hold_Contents) {&Count=&Count+1}} {#NEW cobycount object=@Hold_Contents count=1}}
    }
  #VIEW cobycount
  #DBFIRST
  #WHILE (!%null( %rec)) {
    #SHOW %format( "&5.0f &s &s", &count, " ", &object)
    #DBNEXT
    }
  #SHOW -------------------------------------------------------------------------------
  }
#CLASS 0
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 19, 2011 1:14 am   
 
What looks like this exact same code is being discussed in another thread. That thread includes much improved code:
http://forums.zuggsoft.com/forums/viewtopic.php?t=36784
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