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
Zerboxx
Newbie


Joined: 28 May 2004
Posts: 9
Location: Canada

PostPosted: Tue Jul 06, 2004 6:30 am   

A database script
 
Hi, I'm attempting to set up a script that will do the following:
When I hit a button (Vial Check), it activates a trigger, that when it see's:
"vial(%n)" a rosewood vial
it then procedes to PROBE that set of numbers, and when probed it will look for the following lines (also to be triggered):
It has (%n) months of usefulness left.
and
* of (%w) sloshes about in it.
So with all of this information (vial number, months left, and whats in it. I would like it to enter that information into a database.
Is this possible? and if so any pointers would be a great help!
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Jul 06, 2004 5:52 pm   
 
#TR VialCheck {vial(%d)} {#ADDK Vial Number %1;probe %1}
#COND {It has (%d) months of usefulness left.} {#ADDK Vial Months %1}
#COND {of (%w) sloshes about in it.} {#T- VialCheck;#ADDK Vial Type %1}
#T- VialCheck

And the button's Value should include the lines
#T+ VialCheck trigger
#STATE VialCheck 0

The contents of the variable may be added to the database using the #NEW command. If you want to modify an existing record, that can be done with #DBPUT.

I don't actually recommend a database for this. A pair of record variables, one for Months and the other for Type with both using the vial Numbers as keys, would be much easier to access and maintain. For that, the trigger would be:
#TR VialCheck {vial(%d)} {probe %1}
#COND {It has (%d) months of usefulness left.} {#ADDK VialMonths %t1 %1}
#COND {of (%w) sloshes about in it.} {#T- VialCheck;#ADDK VialType %t1 %1}
Reply with quote
Zerboxx
Newbie


Joined: 28 May 2004
Posts: 9
Location: Canada

PostPosted: Tue Jul 06, 2004 11:08 pm   
 
I see how some of this works LightBulb, but there's still a problem:
#1 I used the bottom trigger, and, when it sees the vial### it probes it, that's wonderful, but I don't see where the #addk values go.
also
#2 It only does this to the first vial, and the output is more like this:
You are holding:
"vial#####" a tulipwood vial
"vial######" an orangewood vial
"vial######" a chestnut vial
etc etc
You are wearing:

Hope it's still possible, and thanks again for your help.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jul 07, 2004 6:11 am   
 
The information from #ADDKEY goes in the variable which is named immediately after the command. For the first one that's @VialMonths and for the second it's @VialType.

Obviously, since you want to use the trigger to store the vial number in a variable, then probe the vial, and then combine the information from the probe with the number in the variable, you can't have the trigger start on a second vial until the first vial is finished. If you did start on another vial without waiting, by the time you got the information from the first probe you'd have the wrong number in the variable! If you want to check more than one vial you'll need to put your vials in a container as you finish checking each one.

However, with the additional information and clearer description of what you want instead of how to do it, I think I could write a script that gives you the information you want. Basically, it's just a matter of putting all the vial numbers in a list and then, after each vial's probe is finished, removing its number from the list and probing the next one.

#VAR Vialcheck 0 0
#TR {vial(%d)} {#ADDI VialList %1;#IF !(@Vialcheck) {#VAR Vialcheck 1;probe %item( @VialList, 1)}}
#TR {It has (%d) months of usefulness left.} {#IF (@Vialcheck) {#ADDK VialMonths {%item( @VialList, 1)} %1}}
#COND {of (%w) sloshes about in it.} {#ADDK VialType {%item( @Vialcheck, 1)} %1;#DELN VialList 1;#IF %numitems( @VialList) {probe %item( @VialList, 1)} {#VAR Vialcheck 0}}
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