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


Joined: 01 Sep 2002
Posts: 11

PostPosted: Thu Sep 12, 2002 5:24 am   

Database help please...
 
Ok.. I get really confused trying to figure out the database because my mud's output is different than the standard template just enough to confuse me... Here's a sample, what I want to do is type recite tablet sword
get the results as shown and have it automatically do into the database...

You recite a tablet of Identification.

Object 'the admin head's bastard sword' is a weapon, with wear location: wield
Special properties: magic
Its weight is 25, value is 0, and level is 58.
Damage is 16 to 51 (average 33).
Weapon appears to be of type 'short blades'.
Affects armor class by -15.
Affects hit roll by 6.
Affects damage roll by 6.
Affects save vs breath by -3.

any help would be greatly appreciated...

Najl
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Sep 12, 2002 1:36 pm   
 
What do you find confusing?
The basic method is recite the identification tablet. Using triggers, match the phrases and assign the identification info to key-value pairs in a record variable. When you reach the end of the identification info, use the #NEW command to add it all to the database.

#TR {^You recite a tablet of identification} {#VAR newdata %null;#VAR affects 0;#T+ newdata}
#CLASS newdata disable
#TR {Object ~'(*)~' is {a|an} (%w), with wear location: (%w)} {#ADDKEY newdata name {%1};#ADDKEY newdata type {%2};#ADDKEY newdata newdata location {%3}}
#TR {Special properties: (*)} {#ADDKEY newdata special {%1}}
#TR {Its weight is (%d), value is (%d), and level is (%d).} {#ADDKEY newdata {weight=%1|value=%2|level=%3}}
#TR {Damage is (%d) to (%d) ~(average (%d)~)} {#ADDKEY newdata {damlow=%1|damhigh=%2|damave=%3}}
#TR {Weapon appears to be of type ~'(*)~'.} {#ADDKEY newdata wtype {%1}}
#TR {Affects (*).} {#IF (@affects) {#VAR affects {@affects, %1}} {#VAR affects {%1}}}
#TR {$} {#IF (@affects) {#ADDKEY newdata affects {@affects}};#NEW all @newdata;#T- newdata}
#CLASS 0


Naturally, this depends on you having an open database with the appropriate fields.

LightBulb
Senior Member
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Thu Sep 12, 2002 1:58 pm   
 
Thats the problem so to speak, I'm not sure what the appropriate fields should be...
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Thu Sep 12, 2002 2:30 pm   
 
I followed what you wrote and made fields matching the text... cut and pasted your text so it generated all the info/triggers/Vars correctly... it adds blank records when I recite tablet... I know something is wrong.. I just don't know what?
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Thu Sep 12, 2002 10:42 pm   
 
I made these fields;
Name text
type text
with wear location: text
Special properties: text
Its weight is general numeric
value is general numeric
and level is general numeric
Affects armor class by general numeric
Affects hit roll by general numeric
Affects damage roll by general numeric
Affects save vs breath by general numeric

I copied what you wrote LB straight onto the command line and hit enter, It made me triggers, when I recite tablet sword for intance, I get a new record... but no data fills in the fields... Sorry... I'm not a programer.. I can write real simple triggers and thats about all I know how to do... Did I miss something??

Najl
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 4:59 am   
 
For some unknown reason, you have to make the first record in the database yourself. Go to the database screen, and enter the information for an item. You can use the actual information or just make something up. Once there's one record, you should be able to add additional records with the script. And once you have a few records successfully in place, you can delete the record you made manually (if it was made-up info).

The fields I used in my example don't match the ones you made. The fields I used (with suggested field-types) are:
Name (text)
Type (text)
Location (text)
Special (text)
Weight (general numeric)
Value (general numeric)
Level (general numeric)
Damlow (general numeric)
Damhigh (general numeric)
Damave (general numeric)
Wtype (text)
Affects (text)

I didn't actually make a database, so the field-types are only suggestions. You might prefer to use other types, such as option-list for location or wtype. Its your database, feel free to make it suit your needs.

You don't have to use all the fields I provided triggers for. However, if you don't plan on using a field, you probably shouldn't put it in the variable. Just remove the appropriate #ADDKEY command.

Remember that the database window has to be open to add data to the database. In fact, the database window has to be open to do anything with the database. However, it doesn't have to be the top window and it's okay to minimize it -- just don't close it until you're done with the database.

LightBulb
Senior Member
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Fri Sep 13, 2002 5:28 am   
 
Thank you for the help... I used the fields you had... It creates a blank record even after I hand entered 2... I don't wish to bother you but any other suggestions?

Najl
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 5:58 am   
 
What is the value of @newdata?
Type #VAR newdata
then just cut-and-paste whatever it shows.

If it's getting most of the data into @newdata, it may be the final trigger. I assumed from your first post that there would be a blank line at the end of the identification information. If that's not true, then nothing will happen until there is a blank line.

LightBulb
Senior Member
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Fri Sep 13, 2002 1:57 pm   
 
#var newdata is empty, I both typed it and used the variables button on the tool bar to look.. nothing... Wild guess here.. thats the problem, something is not correct and it's not writing to that var?

Najl
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 4:29 pm   
 
Yes, if nothing is being stored in @newdata then the whole script isn't working. That's probably because most of the script is in a disabled class so it won't interfere when you aren't identifying stuff. However, the trigger that enables the class has to be outside it.

Most of the triggers should be in the newdata class. The first trigger is the one that enables the script, so it should be in the None class.
#TR {^You recite a tablet of identification} {#VAR newdata %null;#VAR affects 0;#T+ newdata}


LightBulb
Senior Member
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 4:38 pm   
 
Reviewing the script also reveals a typo in the second trigger, where I repeated "newdata".
#TR {Object ~'(*)~' is {a|an} (%w), with wear location: (%w)} {#ADDKEY newdata name {%1};#ADDKEY newdata type {%2};#ADDKEY newdata newdata location {%3}}


LightBulb
Senior Member
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Fri Sep 13, 2002 9:57 pm   
 
It adds the new record into the database but the record is blank still...Var newdata is empty.... I fixed the typo and it still doesn't work... I have no clue here, Thank you very much for helping...

Najl
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Sep 13, 2002 10:06 pm   
 


You recite a tablet of Identification.
< null line.
Object 'the admin head's bustard sword' is a weapon, with wear location: wield
Special properties: magic
Its weight is 25, value is 0, and level is 58.
Damage is 16 to 51 (average 33).
Weapon appears to be of type 'short blades'.
Affects armor class by -15.
Affects hit roll by 6.
Affects damage roll by 6.
Affects save vs breath by -3.
< null line.


Issue might have to do with spaces and the null line after the recite which I kludged with variable SkipMe. I added #CO 71 so you can visually see if the line is being matched or not. What shows up in white on red and what doesn't? I added #VAR newdata at the end so you can see what it stored as well.

Let me see if I can sum LightBulb's work:

#TR {^You recite a tablet of identification} {#CO 71;#VAR newdata %null;#VAR affects 0;#T+ newdata;#VAR SkipMe 1}
#CLASS newdata disable
#TR {Object ~'(*)~' is {a|an} (%w), with wear location:%s(%w)} {#CO 71;#ADDKEY newdata name {%1};#ADDKEY newdata type {%2};#ADDKEY newdata location {%3}}
#TR {Special properties:%s(*)} {#CO 71;#ADDKEY newdata special {%1}}
#TR {Its weight is (%d), value is (%d), and level is (%d).} {#CO 71;#ADDKEY newdata {weight=%1|value=%2|level=%3}}
#TR {Damage is (%d) to (%d) ~(average (%d)~)} {#CO 71;#ADDKEY newdata {damlow=%1|damhigh=%2|damave=%3}}
#TR {Weapon appears to be of type ~'(*)~'.} {#CO 71;#ADDKEY newdata wtype {%1}}
#TR {Affects (*).} {#IF (@affects) {#CO 71;#VAR affects {@affects, %1}} {#VAR affects {%1}}}
#TR {$} {#IF (@SkipMe) {#VAR SkipMe 0} {#IF (@affects) {#ADDKEY newdata affects {@affects}};#NEW all @newdata;#T- newdata;#VAR newdata}}
#CLASS 0


Ton Diening
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 11:06 pm   
 
Thanks Ton, I was pulling my hair out on this one. Never even noticed it probably starts with a blank line.

LightBulb
Senior Member
Reply with quote
Najl
Beginner


Joined: 01 Sep 2002
Posts: 11

PostPosted: Sat Sep 14, 2002 4:37 pm   
 
Thanks guys........ It works now....

Najl
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