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


Joined: 04 Sep 2002
Posts: 1
Location: USA

PostPosted: Tue Sep 10, 2002 5:09 am   

Semi-Advanced Scripting
 
I've been working on my database scripts for JediMUD for a week or so now and have nearly completed them. I have come across one last hurdle and am looking to the forum for some help. My question is about Triggers reading text that span over multiple lines. For instance, my problem lies in when I'm identifying scrolls/wands/staves etc., anything that could potentionally have a spell attached to it. The output from an identify is thus:

You feel informed:
Object 'scroll identify', Item type: SCROLL
Item is: MAG
Weight: 1, Value: 1000, Minimum Level: 0
Level 12 spells of:
identify

or it could be one that has more than one spell attached to it, up to a max of three.

You feel informed:
Object 'scroll recall', Item type: SCROLL
Item is: MAG
Weight: 1, Value: 1000, Minimum Level: 0
Level 12 spells of:
word of recall
control weather
control weather

The spell part of the identify is the end of the information I need to collect. The database has 3 fields, Spell_1, Spell_2, Spell_3 as well as there are 3 variables of the same name. It will be a Single Option with add other selected. (Maybe later go to an options list, but I want it to work first.) Any help would be gladly appreciated and if anyone needs more info, reply with what you need or email me and I'll get back to you. I'm gonna be working on it, and eventually once it's completed I'll post a majority of the scripts. There great to have around and the database is amazing. Great Job Zugg.


Chris

And when I saw the darkness come.....I ran.
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Tue Sep 10, 2002 12:15 pm   
 
The 3 variables you are using for the spells are not necessary. Everything can go into a single database variable before it is put into the database. From the helpfile:

quote:
#NEW Weapon @Item
Creates a new record in the Weapon view using data from the @Item database variable


So, assuming there is a blank line after the spells, you could do something like:

#CLASS {CaptureValues}
#ALIAS savetodatabase {#NEW "" @databasevariable}
#VAR databasevariable %null
#VAR Counter {1}
#TRIGGER {^Level (%d) spells of:$} {
#ADDKEY databasevariable SpellLevel %1
#VAR Counter 1
#T+ {CaptureValues|CaptureSpells}
}
#TRIGGER {^You feel informed.$} {#VAR databasevariable %null}
#TRIGGER {^Object '(*)', Item type: (%w)$} {
#ADDKEY databasevariable Object "%1"
#ADDKEY databasevariable ItemType "%2"
}
#TRIGGER {^Item is: (%w)$} {#ADDKEY databasevariable ItemIs "%1"}
#TRIGGER {Weight: (%d), Value: (%d), Minimum Level: (%d)} {
#ADDKEY databasevariable Weight %1
#ADDKEY databasevariable Value %2
#ADDKEY databasevariable MinLevel %3
}
#CLASS 0
#CLASS {CaptureValues|CaptureSpells} {disable}
#TRIGGER {^(*)$} {
#IF ("%1" =~ "^Level %d spells of:$") {#ABORT 1}
#ADDKEY databasevariable spell@Counter "%1"
#ADD Counter 1
#IF (@Counter > 3) {
#T- {CaptureValues|CaptureSpells}
savetodatabase
}
}
#TRIGGER {^$} {
#WHILE (@Counter <= 3) {
#ADDKEY databasevariable spell@Counter %null
#ADD Counter 1
}
#T- {CaptureValues|CaptureSpells}
savetodatabase
}
#CLASS 0


 - Charbal
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