Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
etali
Beginner


Joined: 22 Aug 2003
Posts: 12
Location: United Kingdom

PostPosted: Fri Aug 22, 2003 10:19 pm   

Trigger / DB question
 
I'm fairly new to zMud scripting. I thought I was getting somewhere but I've got a wierd problem.

I've got this alias to check an inventory and add everything in it to a database:

#TRIGGER {^("*")%s(*).} {
#echo ok
#new summary item_number=%%1 owner_name=me decays=0 date_seen=1
#UNTRIGGER {^("*")%s(*).}
}

The thing is, while it will match:

"pouch92660" a leather herb pouch.

and

"blue potion89356"a blue potion.

It gets them wrong when adding them to the database.

It adds pouch92660 just fine, but blue potion89356 comes out just as potion80956

I'd be very grateful if someone could explain what I'm doing wrong.

I'd also like to add the text 'A blue potion' and 'a leather herb pouch' to a field item_name , but since I can't get the item_number to work I'm not doing that.

Thanks in advance.

--
Etali
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 23, 2003 2:19 am   
 
I can't see anything in your trigger to explain the number change. If it's not a typo, you have something else in your scripts making the change (#SUB, maybe?). It probably drops the "blue" at the same time.

If that's not the problem, I don't know what's causing it but a record-variable should clear it up.

#TRIGGER {^("*")%s(*).} {
#ECHO ok
#VAR tempdb ""
#ADDK tempdb {owner_name=me|decays=0|date_seen=1}
#ADDK tempdb {item_number=%%1|item_name=%%2}
#NEW summary @tempdb
#UNTRIGGER {^("*")%s(*).}
}

By the way, you don't have a space in
"blue potion89356"a blue potion.
It that's not a typo, it might also be contributing to your difficulties although it should just mean the trigger won't match.
Reply with quote
etali
Beginner


Joined: 22 Aug 2003
Posts: 12
Location: United Kingdom

PostPosted: Sat Aug 23, 2003 11:43 am   
 
Hi

Thanks for your answer.

I did make a typo with the potion number - What I meant was instead of, say 'blue potion999' it comes out as 'potion999' - I want it to add the word blue as well as the potion bit.

The lack of a space on one of my examples was accurate though. It matches ok as far as I can tell. Is there a better way to match both 'any number of spaces' and 'no spaces'?

Thanks again.

--
Etali
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 23, 2003 4:57 pm   
 
%s matches any amount of white space -- except 0. Instead of trying to match the leading spaces, just remove them. %trim removes any number of leading and trailing spaces -- including 0.
#TRIGGER {^("*")(*).} {
#ECHO ok
#VAR tempdb ""
#ADDK tempdb {owner_name=me|decays=0|date_seen=1}
#ADDK tempdb {item_number=%%1|item_name=%trim("%%2")}
#NEW summary @tempdb
#UNTRIGGER {^("*")(*).}
}
Reply with quote
etali
Beginner


Joined: 22 Aug 2003
Posts: 12
Location: United Kingdom

PostPosted: Sat Aug 23, 2003 7:53 pm   
 
Thanks lightbulb! That worked great :>

The only problem was that it was untriggering after the first item in the list, and not catching the others, which my version didn't do??

I've 'fixed' that by moving the un-trigger to outside the #Trigger and puting a wait 5000 in front of it. Is there a better way?

Thanks again.

Etali (Hoping one day she'll actually get all this stuff to make sense.)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 23, 2003 9:18 pm   
 
The untrigger is from your version, except that the pattern was changed to match the change in the trigger pattern. A one-time alarm might be a better choice, #WAIT is intended for slowing loops.
#ALA +5 {#UNTR {^("*")(*).}}
Reply with quote
etali
Beginner


Joined: 22 Aug 2003
Posts: 12
Location: United Kingdom

PostPosted: Sat Aug 23, 2003 11:33 pm   
 
I wasn't criticising anything by saying the untrigger in your version was wrong - I realise they're in the same place in both my version and yours - thats why I commented. It seems strange that my version will process every item in a list, and your, very similar one in that respect, only does the first item.

I hadn't known about alarms. Thanks for the tip. I'll change it.

Thanks again.

--
Etali
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Aug 24, 2003 3:27 am   
 
I can't explain why yours didn't untrigger after the first item in the list or at least the first matching item. It should have.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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