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
Ereptor
Beginner


Joined: 24 Aug 2004
Posts: 14
Location: Philadelphia

PostPosted: Tue Sep 07, 2004 8:32 pm   

Script/Trigger to Database
 
Ok, I'm new to this so please bear with me. I'm the admin on my mud, I'm trying to compile a database of equipment.
I've got the database built in zMud with the following fields:
Name,
Level,
Type,
Average Damage,
Damage Bonus,
Hit Bonus,
Restrictions,
Flags,
Weight,
Damage Type,
Other Affects.

I want to be able to capture the info when I stat an object so long as the Type: Weapon When I stat an object it reads as this (text that's red, well actually what's following, is what I'd like to capture):

Name(s): castellan sword longsword
Vnum: 31031 Format: new Type: weapon Resets: 1
Short description: the Castellan's Longsword
Long description: The Castellan's Longsword is lying here in the dirt.
Wear bits: take wield
Fit bits: none
Extra bits: magic
More Extra bits: none
Restrictions: evil harmful
Number: 1/1 Weight: 250/250/250 (10th pounds)
Level: 49 Cost: 2000 Condition: 0 Timer: 0
In room: 0 In object: (none) Carried by: (none) Wear_loc: -1
Values: 1 6 7 3 0
Weapon type is sword
Damage is 6d7 (average 24)
Damage noun is slash.
Affects hit roll by 2, level 49.
Affects damage roll by 2, level 49.

Now I've refrenced http://www.silverbridge.org/~varmel/zmud/tutorials/zmuddb.htm
but I'm not really sure how to go about this.... now I get that I want my triggers to look like this...
#TRIGGER {Name: &weapon.Name} {}
#TRIGGER {Type: &weapon.Type}{}
Hopefully I've read that correctly on another post where it begins with the mud's outputted text followed by &database.field
but that's about as far as I can figure out. Is there anyone whom wouldn't mind helping me out on this? I'd greatly appreciate it.
_________________
Graciously Yours,
Dave
-----------------
There is a fine line between insanity and genious, where do you stand?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 08, 2004 3:18 am   
 
Actually, I prefer triggers which look like this.
#TR {Name: (*)} {#ADDKEY weapon Name {%1}}
#TR {Type: (*)} {#ADDK weapon Type {%1}}
I find them easier to understand, especially when using wildcards such as %w or %d to limit the amount of information captured. They also allow the use of multiword keys to match your multiword Field names.

I've assumed standard spacing, if there are additional spaces anywhere you might need to adjust the patterns.
Code:
#TR {Name(s): (*)} {#ADDK weapon Name {%1}}
#TR {Restrictions: (*)} {#ADDK weapon Restrictions {%1}}
#TR {Number: %d/%d Weight: (%d/%d/%d)} {#ADDK weapon Weight {%1}}
#TR {Level: (%d)} {#ADDK weapon Level {%1}}
#TR {Weapon type is (%w)} {#ADDK weapon Type {%1}}
#TR {Damage is %dd%d ~(average (%d)} {#ADDK weapon {Average Damage} {%1}}
#TR {Damage noun is (%w)} {#ADDK weapon {Damage Type} {%1}}
#TR {Affects hit roll by (%d)} {#ADDK weapon {Hit Bonus} {%1}}
#TR {Affects damage roll by (%d)} {#ADDK weapon {Damage Bonus} {%1}}


P.S. I don't recommend multiword Field names
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Ereptor
Beginner


Joined: 24 Aug 2004
Posts: 14
Location: Philadelphia

PostPosted: Wed Sep 08, 2004 1:47 pm   
 
Ok, I see how that works, does that sit in a DB anywhere that I'd be able to export after a while? Also would a command like this work?
#TR {Affects (%w) by (%d)} {#ADDK weapon {Other Affects} {%1 %2}}
My mud spits out stuff like "Affects saves by -1" or "Affects Charisma by 8" all I need to see is saves -1 or Charisma 8. I tried it like that but it doesn't seem to want to work. So far the multiword field in restrictions seems to work ok...
Also is there a way to only get those triggers you have above to go off when the line reads with weapon as the type?
Vnum: 31031 Format: new Type: weapon Resets: 1
_________________
Graciously Yours,
Dave
-----------------
There is a fine line between insanity and genious, where do you stand?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 08, 2004 6:06 pm   
 
No, it doesn't sit in a DB anywhere. It sits in a variable, where it can easily be added to a database, but it isn't actually added to a database until you issue the #NEW command. This allows you to check for previous entries, so you don't end up with 50 identical entries for "castellan sword longsword". To add it to the current database, use this line or something similar.
Code:
#NEW All @weapon


%d only matches the digits 0-9. Since this could include negative numbers, use %n which also matches the - symbol. You should also do this with any other lines which might use negative numbers (hit roll and damage roll, for instance).
Code:
#TR {Affects (%w) by (%n)} {#ADDK weapon {Other Affects} {%1 %2}}


All of the triggers except the first one (Name) can be moved to a trigger class with any name you choose (I'll use WeaponID). The first trigger can't be in that class because its line comes before the Vnum-Format-Type-Resets line.

The class should be set to "Disable class when connecting to a MUD". You can then enable the class with the Vnum-Format-Type-Resets line and disable it after you receive the last line of the ID (for instance, when you receive a prompt). The trigger which enables the class (#T+) must be outside the class. The trigger which disables the class (#T-) can be included in the class, so that it won't overwrite similar triggers.
Code:
#TR {Vnum: %d Format: %w Type: (%w)} {#IF (%1 = "weapon") {#T+ WeaponID} {#T- WeaponID}}
#TR {H: (%n) M: (%n) V: (%n)} {#T- WeaponID} {WeaponID} {prompt}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Ereptor
Beginner


Joined: 24 Aug 2004
Posts: 14
Location: Philadelphia

PostPosted: Wed Sep 08, 2004 9:10 pm   
 
Hrm, now I'm not getting anything inputted to the weapon variable at all.

#CLASS {WeaponID} {disable}
#TRIGGER {Name~(s~): (*)} {#ADDK weapon Name {%1}}
#TRIGGER {Restrictions: (*)} {#ADDK weapon Restrictions {%1}}
#TRIGGER {Number: %d/%d Weight: (%d)/%d/%d} {#ADDK weapon Weight {%1}}
#TRIGGER {Level: (%d)} {#ADDK weapon Level {%1}}
#TRIGGER {Weapon type is (%w)} {#ADDK weapon Type {%1}}
#TRIGGER {Damage is %dd%d ~(average (%d)} {#ADDK weapon {Average Damage} {%1}}
#TRIGGER {Damage noun is (%w)} {#ADDK weapon {Damage Type} {%1}}
#TRIGGER {Affects hit roll by (%n)} {#ADDK weapon {Hit Bonus} {%1}}
#TRIGGER {Affects damage roll by (%n)} {#ADDK weapon {Damage Bonus} {%1}}
#TRIGGER {Affects (%w) by (%n)} {#ADDK weapon {Other Affects} {%1 %2}}
#TRIGGER {H: (%n) M: (%n) V: (%n)} {#T- WeaponID} "" {prompt}
#CLASS 0

I took your suggestion and added the class and trigger to execute the class, was I also correct in adding the ~ in the 1st trigger line? but something else still ain't right. Ya'll have the patience of gods to be doing this stuff all the time, I'm ready to eat my computer right now.
_________________
Graciously Yours,
Dave
-----------------
There is a fine line between insanity and genious, where do you stand?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Sep 09, 2004 12:46 am   
 
Quote:
was I also correct in adding the ~ in the 1st trigger line?

Yes
Quote:
but something else still ain't right.

posibbly because your not enabling the class #T+ whatever class ids are in
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