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
Talbourne
Novice


Joined: 19 Dec 2000
Posts: 39

PostPosted: Sun Feb 02, 2003 1:32 pm   

help with #f and database var's
 
Databasing..isn't it fun? I capture the folling from my mud..

Object: armor holy Type: armor
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Flags: bless anti-evil anti-mage anti-thief anti-warrior anti-ranger anti-sage anti-bard anti-assassin anti-psionist anti-necromancer engraved !war !asn !thi
Weight: 45 Value: 5600 Level: 96
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Armor class: 35
Location: take body
Condition: [perfect]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Affects hp by 80
Affects mana by 150
Affects armor class by -20
Affects save vs spell by -4
Affects damage roll by 3
Affects hit roll by 5
Affects dexterity by -1
Affects mana by 76
Affects hp by 76


What I'm needed help with is the affects list (unless someone can suggest a way to parse out the flags so I can import into the database as a multiple option list, rather then text like I'm doing now) I use the following trigger on the affects list.
#tr {#if (!%null( @newrecord.%1)) {#ad newrecord.%1 %2};{#addkey newrecord {%1} %2}} {Affects (*) by (*)}

It usally workse fine, except when I get items with dupplicated affects, in which case I need to add them together, to do that I need to see if there is already anything there, which again is fine for most affects, except for dam roll, hit roll, and armor class (I don't care about the others). I can create a new database variable using brackets, but I can't compare using those brackets, so the trigger ends up comparing the wrong fields, or adding the wrong fields, or instaed of armor class set at -20, I'll end up with a field called armor, with a value called class, because the comparison went off wrong. I had this working, but mud crashed and triggers didn't save, now I can't remember what I did.. this is the short version of what I did, I made another set of triggers that looks like this:

#if ((%1)=(damage roll) & !%null( @newrecord.damage_roll)) {
#ad newrecord.damage_roll %2} {
#if ((%1)=(hit roll) & !%null( @newrecord.hit_roll)) {
#ad newrecord.hit_roll %2
} {
#if ((%1)=(armor class) & !%null( @newrecord.armor_class)) {
#ad newrecord.armor_class %2
} {
#if (!%null( @newrecord.%1)) {
#ad newrecord.%1 %2
} {
#if ((%1)=(damage roll)) {
#addkey newrecord damage_roll %2
} {
#if ((%1)=(hit roll)) {
#addkey newrecord hit_roll %2
} {
#if ((%1)=(armor class)) {
#addkey newrecord armor_class %2
} {
#addkey newrecord %1 %2
}
}
}
}
}
}
}

But that's ever worse, with that one, I don't get past damage roll. ANyone have any ideas so I can add 'damage roll' if it's listed multiple times, without having to change field names to single words? and if there isn't a way, can someone suggest an easy way to replace damage roll with damage_roll before the affects trigger goes off?

Thanx in advance.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Feb 02, 2003 5:04 pm   
 
Use the db functions instead of the . notation. That is, instead of:
@record.key
@record.key = 2
#ADD record.key 3

use:
%db(@record, "key")
#VAR record %addkey(@record, "key", 2)
#VAR record %addkey(@record, "key", %eval(%db(@record, "key") + 3))

As for storing the flags as a multiple option list, I think that you can do this by converting it to a stringlist, if I remember correctly. Just store all the flags as a string in a variable and then do:
#VAR flags %replace(@flags, " ", "|")

I believe that if you then pass this stringlist as the value for the list field, it should set to true all the items in the list that are in the stringlist and if you have set the list field to allow new entried, it will create new items in the list field for those that are not already there. Keep in mind that the case of the items in the list field has to be the same as the case of the flags sent by the MUD.

Kjata
Reply with quote
Talbourne
Novice


Joined: 19 Dec 2000
Posts: 39

PostPosted: Sun Feb 02, 2003 9:49 pm   
 
Thank you Kjata, the new fuctions commands work great, and converting flags to a list works great also, thanx for the info!!
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