|
Silvayn Beginner
Joined: 11 May 2002 Posts: 13 Location: Slovakia
|
Posted: Sat May 18, 2002 12:38 pm
Handling Option list field type |
One of the fields in my database is defined as Option list and holds info about the type of the item. I've a trigger that should capture this info (Item type: (%w)) but I don't know how to set it.
I've tried #VA Item.Types.%1 1 and #ADDITEM Item.Types %1, but none of them worked. Any hints? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat May 18, 2002 4:57 pm |
This is all covered in the Database section of the helpfile, particularly the Database Variables topic. A couple of methods would be:
#VAR Item.Types %1
#ADDKEY Item Types %1
NOTE: %1 should be one of the options in the Options List for the Types field.
LightBulb
Vague questions get vague answers |
|
|
|
Silvayn Beginner
Joined: 11 May 2002 Posts: 13 Location: Slovakia
|
Posted: Sun May 19, 2002 12:29 pm |
That works only if there is one type (or i'm doing something wrong). Oh well, I'll try to read through the help file to see if I can find anything.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun May 19, 2002 3:15 pm |
The line "Item type: (%w)" gives the item type in %1. This could be "belt", "boots", "sword", etc. This will work for any of those types or many others. %1 is the information to go in the variable.
The syntax is #VAR db.field value, where db is the name of the database-variable, field is the name of the field in your database, and value is the value you want in that field. In the case of an option-list, the value is not "1" or "0", it's "belt", "armor", "sword", "weapon", "gloves", or some other word(s) that you have as a choice in your option-list. I'm at a loss to understand why you think this won't work.
LightBulb
Vague questions get vague answers |
|
|
|
Silvayn Beginner
Joined: 11 May 2002 Posts: 13 Location: Slovakia
|
Posted: Sun May 19, 2002 4:17 pm |
First off, I thank you LightBulb for trying to help me, I really appreciate it :)
Ok, here is an example of the output: (the line numbers are just for orientation)
1.Divination of (a sparkling mithril shirt).
2.Value:1000 Durability:1000
3.Type: Armour
4.Type: Magical Armour
5.End of divination
Note: the trigger for 3 and 4 is "Type: (*)" so more words can be captured.
Responds:
1. get the name of item, enable other triggers
2. get the 2 numbers
3 & 4. do this: #VAR Item.Types %1
5. save it, disable triggers
As you can (now) see, one item can be of more types, but the #VAR Item.Types %1 syntax causes only the last one to be saved (in this case Magical Armour). |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun May 19, 2002 7:46 pm |
Okay, now I understand the problem at least. Based on the output of #SHOWDB, it appears that multiple options should be separated by a comma followed by a space. That is, your example would be "Armour, Magical Armour". So, write your trigger to check whether there's a value already. If there is, you add the value, preceded by a comma and space. If there's not, you just assign the value.
#TR {Type: (*)$} {#IF (%len(@Item.Types) > 0) {#VAR Item.Types "@Item.Types, %1"} {#VAR Item.Types "%1"}
If this doesn't work, try looking at the database scripts in the Finished Scripts forum for something suitable.
LightBulb
Vague questions get vague answers |
|
|
|
Silvayn Beginner
Joined: 11 May 2002 Posts: 13 Location: Slovakia
|
Posted: Sun May 19, 2002 9:46 pm |
Just wanted to let you know that it finally works :) I should have included the output example right from the start, ohwell next time. Thanks :)
|
|
|
|
|
|