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


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Tue Feb 24, 2004 7:17 am   

Database Issue
 
I think I have a working set of triggers for a identify database, however I'm having a problem getting the last line(s). Following Restricted classes and races it will be either 1 or 2 lines of text listing restrictions, how can I grab that? Once I get this figured out I can test out the rest of them, hopefully they work.

Current bid is: 1111
You feel informed:
This item is in PERFECT condition
Object 'ring black koralne', Item type: ARMOR
Item will give you following abilities: NONE
Can be worn on: TAKE FINGER
Item is: MAGIC !GOOD !NEUTRAL
Weight: 5, Value: 3500
AC-apply is 5
Can affect you as :
Affects : Damroll By 1
Restricted Classes and Races :
Elf, Ogier, Dwarf, Aracoix
Reply with quote
DeReP
Adept


Joined: 14 Jun 2003
Posts: 222
Location: Chile

PostPosted: Tue Feb 24, 2004 8:47 am   
 
#TRIG {Restricted Classes and Races :$(*)} {#ADDKEY variable Restriction %1}
Of corse you would have to set a "Restriction" field on the database
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Feb 24, 2004 2:29 pm   
 
I'm assuming that there will be a blank line after the restricted classes and races lines are finished. If that is the case, just always grab both lines, but don't use the second one if it is blank:
#TRIGGER {Restricted Classes and Races :$(*)$(*)} {#IF ("%2" = "") {use only first line} {use both lines}}

If it is possible that the second line is not blank, then you need a way to determine if it belongs to the restricted classes and races information. You could most likely do this by checking for the precessence of a comma, or a word that is in a list of possible classes and races.
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Wed Feb 25, 2004 10:33 am   
 
Alright stil having some problems with this. Take for example this item.

You feel informed:
This item is in PERFECT condition
Object 'mahogany bracelet', Item type: ARMOR
Item will give you following abilities: NONE
Can be worn on: TAKE WRIST
Item is: MAGIC
Weight: 1, Value: 7000
AC-apply is 0
Can affect you as :
Affects : Damroll By 1
Affects : Con By 1
Restricted Classes and Races :
Magic User, Barbarian, Monk

I have a bunch of triggers set to get data out of here that write it to the variable newrecord. After this I checked the value of @newrecord which looked like

Variable: newrecord name'mahoganytypeARMORabilitiesNONEwornTAKEbitsMAGICacapp0damroll1con1

Now my trigger to get the name and type out, for example, looks like #trigger {^Object (*), Item type~: (*)} {#var newrecord.name %1;#var newrecord.type %2}

Apparently I'm not doing something right though, because it only gets the first word out of most of it. This seems to be a universal problem with all of my triggers that I thought using (*) for my string would allow it to capture all the words including spaces. The restrictions are still not working, either. I used the trigger you recommended but that one won't fire. I don't even really care if it's over one line now that I think about it, only the ones on the first line would be important. Perhaps someone could steer me in the right direction?
Reply with quote
Timas
Novice


Joined: 05 Jan 2003
Posts: 39
Location: Netherlands

PostPosted: Wed Feb 25, 2004 1:08 pm   
 
try putting {} around them.. something like #VAR newrecord.name {%1}
Reply with quote
DeReP
Adept


Joined: 14 Jun 2003
Posts: 222
Location: Chile

PostPosted: Wed Feb 25, 2004 2:37 pm   
 
Ever tryed with &variable type of pattern matching?
Code:

#TRIG {You feel informed:} {#T+ Identify}
#CLASS {Identify}
#TRIG {Object '&newrecord.name', Item type: &newrecord.type}
#TRIG {Item will give you following abilities: &newrecord.abilities}
#TRIG {Can be worn on: &newrecord.worn}
#TRIG {Item is: &newrecord.ItemIs}
#TRIG {Weight: &newrecord.weight, Value: &newrecord.value}
#TRIG {AC-apply is &newrecord.ac}
#TRIG {Affects : Damroll By &newrecord.damroll}
#TRIG {Affects : Con By &newrecord.con}
#TRIG {Restricted Classes and Races :$&newrecord.Restricted}
#TRig {$}{#DBload databasename;#New da @newrecord;#T- Identify}
#CLASS 0

Something like that, It works for me I know. You might want to add a function to check if the item already exists in the database before adding it.
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Wed Feb 25, 2004 8:37 pm   
 
Alright, DeRep, that worked great, except that it only loads one item and then it won't load anymore. The data is being put into the newrecord var fine, it just doesn't go into the database. I got one item in there fine, though! The first item I tried.
Reply with quote
DeReP
Adept


Joined: 14 Jun 2003
Posts: 222
Location: Chile

PostPosted: Wed Feb 25, 2004 10:02 pm   
 
the #NEW command has to be followed by the first 2 characters of the database name
Eg: If the database name is Items you would have to put: #NEW it @newrecord
Also you must consider every case for the item ID, like hitroll, maxmana, maxmove, etc.
Also the database has to be opened, eg: clicking the database button. There is no command to automatically open the database window other than that, #DBload only loads the database you want to use, but the database window has to be opened first.
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Fri Feb 27, 2004 12:45 am   
 
The database button was it, I would have thought #dbload opened the database, but apparently not! So one more question, I grabbed this out of one of the scripts posted in the finished script section to check and see if a duplicate exists.

#IF !%null( %find( @newrecord.name, Equipment, Name)) {#YESNO "A duplicate item already exists, add anyway?" {#NOOP} {#ABORT 1}}

However, according to this every item already exists! I've done some testing with the #find command and it appears that this is returning every result in my database? Not sure whats going on here.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Feb 27, 2004 3:55 am   
 
Ok since I don't use the database this is a shot in the dark

#TRig {$}{#DBload databasename;#IF !%null( %find( @newrecord.name, Equipment, Name)) {#YESNO "A duplicate item already exists, add anyway?" {#New da @newrecord} {#noop}};#T- Identify}
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Fri Feb 27, 2004 7:27 am   
 
Actually, after reading the help files, the %find was mixed up! Changed it to
#IF !%null( %find( @newrecord.name, name, Equipment)) {#ABORT 1}
and it works flawlessly!
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Sun Feb 29, 2004 11:00 am   
 
OK one more question. Been looking through the posts on datbasing but I can't quite figure this one out, either.

This item is in PERFECT condition
Object 'scroll identify', Item type: SCROLL
Item will give you following abilities: NONE
Can be worn on: TAKE HOLD
Item is: MAGIC
Weight: 1, Value: 61
Level 12 spells of:
identify
aid
dispel magic
Restricted Classes and Races :
None

Scrolls/potions look like this, they can have 1-3 spells on them so a looplines won't work (to my knowledge). Best I can think of is to make another class for scrolls and enable it until it reaches the restricted classes?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Feb 29, 2004 2:14 pm   
 
That or something like this I think (still waking up yet again)

#trigger {Level (%d) spells of} {Dbase stuff on level}
#cond {^(*)$} {#IF (%pos( :, %1)) {newrecord.spells="%expandlist(@scroll_spells, " ")";scrolls_spells="";#STATE 0} {#ADDITEM scroll_spells "%1"}} {looppat|param=15}

EDIT: Adding missing "
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Sun Feb 29, 2004 4:16 pm   
 
Ya theres a couple syntax errors in there but not knowing what a lot of that does I can't really tell what they are. I played around trying to get it to work for a little while but kept messing it up even more :) I could use some sleep, but I hate waking up ;)
Reply with quote
rkubiak
Beginner


Joined: 27 May 2001
Posts: 22
Location: USA

PostPosted: Sun Feb 29, 2004 9:36 pm   
 
newrecord.spells = 716H 400M 93V 63592X 718H 407M 95V 63592X vampiric touch Warrior, Paladin, Bard, Ranger, Order Cleric, Barbarian, Monk

vampiric touch is right... the rest of it doesn't belong there :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Mar 01, 2004 5:10 am   
 
Working off nexela's trigger, I am going to assume you want to store the spells as an option list.

#trigger "IDSpellCap" {^Level (%d) spells of:$} {Dbase stuff on level}
#cond {} {#IF (%pos(":",%line)) {newrecord.spells=%replace(@scroll_spells, "|",",");scrolls_spells="";#STATE IDSpellCap 0} {#ADDITEM scroll_spells {%line}}} {looplines|param=5}
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Mar 01, 2004 5:41 am   
 
Yeah what vigilante said is what I wanted to do just watch the typos in scrolls_spells seems that me and Vigilante both missed em
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