Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
boblinski
Novice


Joined: 05 Dec 2005
Posts: 49
Location: New Zealand

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
boblinski
Novice


Joined: 05 Dec 2005
Posts: 49
Location: New Zealand

PostPosted: Sat Feb 03, 2018 1:46 pm   
 
Works great thanks!!

How hard would it be to add one more field in as a "location"?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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