|
boblinski Novice
Joined: 05 Dec 2005 Posts: 49 Location: New Zealand
|
Posted: Sat Feb 03, 2018 8:25 am
Keeping a record of things and what they do |
Wanting to make a list of potions/pills/foods and what they do.. here's an example
things that do 'return':
(Glowing) a potion of return
potion of mud and honey
a potion of recall
things that do 'cure_poison':
a tan pill
things that do 'cure_plague':
a small bag of brown dust
things that do 'teleport':
a green potion
I'd like to be able to enter these with an alias, maybe something like
Code: |
potionAdd {what it does} {name of thing}
potionAdd cure_poison {a tan pill} |
then I'd like to be able to type 'potions' and display:
Quote: |
cure_plague - a small bag of brown dust
cure_poison - a tan pill
return - (Glowing) a potion of return
return - a potion of recall
return - potion of mud and honey
teleport - a green potion |
or be able to type 'potions return' and display:
Quote: |
return - (Glowing) a potion of return
return - a potion of recall
return - potion of mud and honey |
or 'potions cure_poison:
Quote: |
cure_poison - a tan pill |
or maybe even 'potions cure':
Quote: |
cure_plague - a small bag of brown dust
cure_poison - a tan pill |
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Feb 03, 2018 8:43 am |
Code: |
#ALIAS potionAdd {
$effect=%1
$item=%2
$list=%db(@potionsList, $effect)
#IF (!%ismember($item, $list)) {
#ADDITEM $list $item
#ADDKEY potionsList $effect $list
}
} |
And:
Code: |
#ALIAS potions {
#IF (%1) {
#PRINT %1
#SHOWDB @potionsList.%1
} {
#FORALL %dbkeys(@potionList) {
#PRINT %i
#SHOWDB @potionsList.%i
}
}
} |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
boblinski Novice
Joined: 05 Dec 2005 Posts: 49 Location: New Zealand
|
Posted: Sat Feb 03, 2018 1:46 pm |
Works great thanks!!
How hard would it be to add one more field in as a "location"? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon Feb 05, 2018 1:01 am |
Not hard at all, you would just need to reference one layer deeper, or alternatively, use another single layer database in the same format and use the output of one database as a reference tool for the other.
Between this example and others, I have supplied you with the other threads, you should be able to cobble something together yourself.
Give it a try! |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|