|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Sat Nov 22, 2003 7:35 pm
Adding to a database |
I've gotten a script that identifies eq and puts it in a database, except there's a little problem. It catches the type and stats of the item just fine and puts it properly into the variable and database, but the first key, the name, just doesn't get added to the database. Instead, usually the type duplicates. Here's how it looks
You feel informed:
Object 'a sturdy leather backpack', Item type: CONTAINER
Can be worn on: ABOUT
Item is: NOBITS
Weight: 1, Value: 49
Weight Capacity: 175, Weightless: 50
It captures everything into @item, which looks like this:
NAME=a sturdy leather backpack|TYPE=CONTAINER|WEAR=ABOUT |ITEMIS=NOBITS |WEIGHT=1|VALUE=49|WCAPACITY=175|WEIGHTLESS=50
Then triggering on the next line
#DBLOAD he
#NEW all @Item
#DBSAVE he
Which puts it all into the database. Type, Wear, Itemis, Weight, Value, WCapacity and Weightless enters just fine, but Name also becomes Container. The triggerpattern for name and type is
Object '&item.Name~'~, Item type: &item.type
Thoughts? |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Sat Nov 22, 2003 8:20 pm |
try instead to go the longer route
Have your trigger capture everyting into one string list
use a temp to shut the trigger down
You feel informed:
Object 'a sturdy leather backpack', Item type: CONTAINER
Can be worn on: ABOUT
Item is: NOBITS
Weight: 1, Value: 49
Weight Capacity: 175, Weightless: 50
so would be
trigger {You feel informed~:} {#temp {^$} {#t- info;#DBLOAD he;#NEW all @Item;#DBSAVE he};#t+ info}
trigger "info" {(*)} {info="%1"}
start playing with this use %replace to remove things you don't want untill you get something like this:
a sturdy leather backpack|CONTAINER|ABOUT|NOBIT|1|49|175|50
then use maybe %item to finish it
#addkey item name %item(@info,1)
so fort and so on
or you can do this:
trigger {You feel informed~:} {#temp {^$} {#t- info;#DBLOAD he;#NEW all @Item;#DBSAVE he};#t+ info}
#class {info}
#trigger {Object '(*)', Item type: (%w)} {#addkey info name "%1";#addkey info type %2}
and so forth and so on
#trigger Can be worn on: ABOUT
#trigger Item is: NOBITS
#trigger Weight: 1, Value: 49
#trigger Weight Capacity: 175, Weightless: 50
#class 0 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Nov 23, 2003 7:27 pm |
Please provide the entire script. The one trigger pattern you provided would create a variable, @Item, which looks like this (a record variable):
NAMEa sturdy leather backpackTYPECONTAINER
not like this (a list variable):
NAME=a sturdy leather backpack|TYPE=CONTAINER
Obviously, you must do something else to change the variable-type and without knowing what you did, it's impossible to tell you how to correct it. The best advice I could give you is to use a record variable.
#TR {Object '&item.Name', Item type: &item.type}
#NEW all @Item
Notice that the trigger consists only of the pattern. Since the variable fields are created by the pattern there's no need for additional commands. |
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Sun Nov 23, 2003 10:50 pm |
*holds up the obligatory "i'm an idiot" sign*
#CLASS {identify} {disable}
#TRIGGER {object '&Item.name~'~, Item type: &Item.type} {}
#TRIGGER {Capacity: &item.d_capacity drink units} {}
#TRIGGER {This POTION casts: &item.P_cast} {}
#TRIGGER {This STAFF casts: &item.S_cast} {}
#TRIGGER {It has &Item.S_max maximum charges and &item.S_current remaining.} {}
#TRIGGER {Damage: &temporal3} {#var temporaln %trim( @temporal3);#var Item.damag %number( @temporaln)}
#TRIGGER {Can be worn on: &Item.worn} {}
#TRIGGER {Item is: &item.itemis} {}
#TRIGGER {Weight: &Item.weight, Value: &Item.Value} {}
#TRIGGER {Damage Dice is &Item.Damage for an average per-round damage of &Item.average} {}
#TRIGGER {Affects: HITROLL By &Item.hit} {}
#TRIGGER {Affects: DAMROLL By &Item.dam} {}
#TRIGGER {Weight Capacity: &Item.wcapacity, Weightless: &Item.Weightless} {}
#TRIGGER {Weightless: &item.D_Weightless drink units} {}
#TRIGGER {AC-apply is &Item.Ac} {}
#TRIGGER {Affects: &temporal} {item.affects = @item.affects @temporal}
#TRIGGER {Race restricts : &Item.Race} {}
#TRIGGER {Item will give you following abilities: &temporal2} {item.abilities = @item.abilities @temporal2}
#TRIGGER {Breaking Probability: &temporal4 percent} {#var Item.Brk_Prob %trim( @temporal4)}
#TRIGGER {This poison affect with: &item.P_Affect} {}
#TRIGGER {Level &Item.level} {}
#TRIGGER {Size of Vial: &Item.Size_Vial} {}
#TRIGGER {This WAND casts: &item.W_cast} {}
#TRIGGER {Difficulty: &item.Diff} {}
#TRIGGER {Magical Bonus: &item.M_Bonus} {}
#CLASS 0
#CLASS {identify2}
#TRIGGER {$} {#T- identify;#Show <@item>;#DBload he;#New all @item;#beep 16;#DBsave he;#T- Identify2}
#CLASS 0
#TRIGGER {You feel informed} {#var Item "";#T+ Identify;#T+ Identify2}
#CLASS {aliass|items}
#ALIAS iden {get identify sack;recite identify %1}
#ALIAS fi {#SHOW %find( "%1", %2)}
#ALIAS item {#var line1 {};#var line2 {};#var line3 {};#var line4 {};#var item %dbget( %1he);#if (@Item.name) {line1 = "Name: ~{@item.name~} "} {};#if (@Item.type) {line1 = @line1 "Type: ~{@item.type~} "} {};#if (@item.itemis) {line1 = @line1 "Item Is: ~{@item.itemis~} "} {};#if (@item.P_cast) {line2 = "Potion Cast: ~{@item.P_cast~} "} {};#if (@item.S_cast) {line2 = @line2 "This STAFF casts: ~{@item.S_cast~} "} {};#if (@item.W_cast) {line2 = @line2 "This WAND casts: ~(@item.W_cast} "} {};#if (@Item.S_max) {line2 = @line2 "It has ~{@Item.S_max~} maximum charges "} {};#if (@Item.worn) {line2 = @line2 "Worn on: ~{@Item.worn~} "} {};#if (@Item.weight) {line2 = @line2 "Weight: ~{@Item.weight~} "} {};#if (@Item.d_capacity) {line2 = @line2 "Drink Capacity: ~{@Item.d_capacity~} "} {};#if (@Item.D_Weightless) {line2 = @line2 "Drink Weightless: ~{@Item.D_Weightless~} "} {};#if (@Item.Value) {line2 = @line2 "Value: ~{@Item.value~} "} {};#if (@Item.Damage) {line2 = @line2 "Damage: ~{@Item.Damage~} "} {};#if (@Item.average) {line2 = @line2 "Average: ~{@Item.average~} "} {};#if (@Item.hit) {line3 = @line3 "Hit roll: ~{@Item.hit~} "} {};#if (@Item.dam) {line3 = @line3 "Dam roll: ~{@Item.dam~} "} {};#if (@Item.damag) {line3 = @line3 "Damage: ~{@Item.damag~} "} {};#if (@Item.wcapacity) {line3 = @line3 "Weight Cap: ~{@Item.wcapacity~} "} {};#if (@Item.Weightless) {line3 = @line3 "Weightless: ~{@Item.weightless~} "} {};#if (@Item.Ac) {line3 = @line3 "AC: ~{@Item.Ac~} "} {};#if (@item.Diff) {line3 = @line3 "Difficulty: ~{@Item.Diff~} "} {};#if (@item.M_bonus) {line3 = @line3 "Magical Bonus: ~{@Item.M_bonus~} "} {};#if (@item.affects) {line4 = @line4 "Affects: ~{@Item.affects~} "} {};#if (@Item.Race) {line4 = @line4 "Race: ~{@Item.Race~} "} {};#if (@item.abilities) {line4 = @line4 "Abilities: ~{@Item.abilities~} "} {};#if (@Item.Brk_Prob) {line4 = @line4 "Break Prob: ~{@Item.Brk_prob~} "} {};#if (@item.P_Affect) {line4 = @line4 "This Poison Affect whith: ~{@Item.P_affect~} "};#if (@Item.level) {line4 = @line4 "Level: ~{@Item.level~} "};#if (@Item.Size_Vial) {line4 = @line4 "Size of vial: ~{@Item.size_vial~} "};#if (@line1) {#say @line1} {};#if (@line2) {#say @line2} {};#if (@line3) {#say @line3} {};#if (@line4) {#say @line4} {}}
#CLASS 0 |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Nov 24, 2003 7:13 pm |
Okay, I'm sorry then. It appears you should be putting the correct information in the database and I don't know why you aren't.
I also don't see anything which would change the format of the @Item variable to Key1=Value1|Key2=Value2|Key3=Value3. You should probably try to track down the trigger/alias which makes this change and disable/remove it. |
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Mon Nov 24, 2003 8:01 pm |
I'm terribly sorry, that's entirely my fault, just made it that way when I tried to copy-paste it here on the forum. The actual variable says data record. Still can't figure out why it puts the name and type as whatever the type is in the database. (I've experimented, putting the name and type last in the record variable and then doing the #new all @item thing) Same thing. Tried not collecting name and type at all, that works and everything else goes where it's supposed to be. *at total loss*
note to self: don't read shakespeare just before posting in a technical forum. |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Mon Nov 24, 2003 9:32 pm |
Do you have more than one Name trigger?, if so they might be conflicting.
And Just for fun I will take your script re write it from scratch and show you how to do this the long, but reliable way of doing it.
Give me an hour at most 3:15 E.S.T |
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Mon Nov 24, 2003 9:45 pm |
I really really really appreciate that! Plucking at (working) scripts to see what makes em tick is neat.
An HOUR? Just hour? Kidding? |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Mon Nov 24, 2003 11:00 pm |
ok I think your problem was this:
#dbsave he
It should be I think #dbsave
here is what i came up with based on your example worked good for me
Cut and Past
everything below
#CLASS {Identify}
#VAR item {}
#TRIGGER {You feel informed:} {#t+ IdItem;item="";#temp {^$} {#t- IdItem;#DBLOAD he;#NEW All @ITEM;#dbsave;#dbreset;#dbclose}}
#CLASS 0
#CLASS {Identify|IdItem}
#TRIGGER {Object '(*)', Item type: (%w)} {#addkey item NAME "%1";#ADDKEY item TYPE %2}
#TRIGGER {Can be worn on: (%w)} {#addkey item WEAR %1}
#TRIGGER {Item is: (%w)} {#addkey item ITEMIS %1}
#TRIGGER {Weight: (%d), Value: (%d)} {#addkey item WEIGHT %1;#addkey item VALUE %2}
#TRIGGER {Weight Capacity: (%d), Weightless: (%d)} {#addkey item WCAPACITY %1;#ADDKEY item WEIGHTLESS %2}
#CLASS 0 |
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Mon Nov 24, 2003 11:47 pm |
Much sensibler that, yeah. Think I can even start to figure it out. You're gonna hate this though, it still puts the type twice. :( I tried logging onto the mud with a blank .mud file and entered your script as the -only- one, same thing. So I tried making a new database, and got "Grid out of range" error. So... It's more trouble than it's worth. Sorry about the extra work.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Nov 25, 2003 6:25 pm |
Check the definition of the Name field in the database. It's not likely, but it is possible you selected Use Formula, with the formula getting the Name from the Type field. This would override whatever you entered with the script.
|
|
|
|
Nyvaana Beginner
Joined: 29 Jun 2002 Posts: 15 Location: Sweden
|
Posted: Tue Nov 25, 2003 9:45 pm |
Always feels good to know there's smart people around to ask.
That might've done the trick Lightbulb, I don't know, managed to make a new database from scratch, and after that (far as I can tell) it stopped. Between your help and the new script, I'm on a Very good start to get a running database. Thanks much! |
|
|
|
|
|