talith Novice
Joined: 03 Mar 2005 Posts: 31
|
Posted: 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 |
|
|