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
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Wed Jun 27, 2018 5:26 am   

Need help building a database of 'research info'
 
Concept for my subguild is to 'gather' 'herbs' (7 kinds) and to develop a 'recipe' using a range of # of herbs <syntax = "recipe <name> # # # # # # #">. We can then 'concoct name' to consume for stats buffs.

The guild has been recently re-coded to use this method and there is a lack of members in the subguild to share info... So I wanted to build up a database of all the results I get from my experimental 'recipes'

I have to date.. triggers that capture when I gather an herb and add +1 to an associated variable. @herbGinseng | @herbThyme | etc. as well as my main 'recipe' alias using #prompt to store the # of used herbs to
reduce the previously mentioned variables by that amount to try and keep accurate record of my total stock... which can be double checks and corrected with the 'herb' command and its capture trigs.

What I want to do is form a table/spreadsheet/database to record on it's own line the recipe value(s) for each herb, and to also check my stats and record the +/- bonuses to matching fields.

Example recipe test 0 20 25 25 5 0 20

would show in the table as. Field Names on top line and the values on all subsequent lines

Ginseng:0 Thyme:20 Nightshade:25 Tigerroot:25 Hemlock:5 Sage:0 Wolfsbane:20 blank_field STR:+6 CON:+6 INT:-4 WIS:+3 DEX:+6 QUI:+6 blank_field Side Effects:Yes/No


Is this possible? ATM I am manually having to do this via google docs and would like to if possible automate the recording of this info.
https://docs.google.com/spreadsheets/d/15t3XRE1z5q_xIgsVUIgPw6dZIT4IUjxGQKUCKXw_1WM/edit?usp=sharing
Reply with quote
shalimar
GURU


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

PostPosted: Wed Jun 27, 2018 6:49 pm   
 
Something like this could be used to define your known recipies:

#ALIAS recipe {
$name=%1
$this=%db(@recipies,$name)
#ADDKEY $this Ginseng %2
#ADDKEY $this Thyme %3
#ADDKEY $this Nightshade %4
#ADDKEY $this TigerRoot %5
#ADDKEY $this Hemlock %6
#ADDKEY $this Sage %7
#ADDKEY $this Wolfsbane %8
#ADDKEY recipies $name $this
}

The stat boosts could be added in the same vein if they are static.
Then to reference what was used in a given recipe: @recipies.test.hemlock
Or a given boost: @recipies.test.dex
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Wed Jun 27, 2018 11:24 pm   
 
I'll give that a shot, the name really isn't important as it will be something for each player to decide what they want to call it. This is more for future reference for any potential new members to the Medic sub-guild.

As for the stat bonuses, they are semi-static... well no apparent pattern to how they increase based on each herb, nearly all seven herbs give +2 Str +1/2 Wis, and +4 Qui ... and that's just the visually noticeable boosts.

I'm working on a pair of captures for the @modifier"Stat" as a variable to tie into the recorded, crafted, consumed recipe for the database, but i'm having some difficulty getting it to capture what I want it.
Code:

                        STATS - Base(Bonus)/Total
         Strength               Constitution           Intelligence
          30(  0)/30             30(  0)/30             25(  0)/25
         Wisdom                 Dexterity              Quickness
          32(+ 6)/38             32(+ 6)/38             30(+11)/41

which I finally managed to figure out how to capture the way I want it.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Thu Jun 28, 2018 6:10 pm   
 
Ok. I feel like I am over complicating things but also may have messed up some how...
Code:
// Create recipe
#PR recipeName "Name of Recipe?"
#PR herbGI "Number of Ginseng?"
#PR herbTH "Number of Thyme?"
#PR herbNI "Number of Nightshade?"
#PR herbTI "Number of Tigerroot?"
#PR herbHE "Number of Hemlock?"
#PR herbSA "Number of Sage?"
#PR herbWO "Number of Wolfsbane?"

recipe @recipeName @herbGI @herbTH @herbNI @herbTI @herbHE @herbSA @herbWO

// Herb Name = current stock, deduct @herbINITIAL of current recipe
Ginseng = @Ginseng - @herbGI
Thyme = @Thyme - @herbTH
Nightshade = @Nightshade - @herbNI
Tigerroot = @Tigerroot - @herbTI
Hemlock = @Hemlock - @herbHE
Sage = @Sage - @herbSA
Wolfsbane = @Wolfsbane - @herbWO

// Add recipe to database
$name=%1
$this=%db(@RecipeResearch,$name)
#ADDKEY $this Ginseng @herbGI
#ADDKEY $this Thyme @herbTH
#ADDKEY $this Nightshade @herbNI
#ADDKEY $this TigerRoot @herbTI
#ADDKEY $this Hemlock @herbHE
#ADDKEY $this Sage @herbSA
#ADDKEY $this Wolfsbane @herbWO
#ADDKEY RecipeResearch $name $this

// Craft recipe, consume sample, record results
concoct @recipeName
vial @recipeName
#SENDRAW {!score}
#WA 2000
// Add to database the captured stat bonuses
// STR = @bonusStrength
// CON = @bonusConstitution
// INT = @bonusIntelligence
// WIS = @bonusWisdom
// DEX = @bonusDexterity
// QUI = @bonusQuickness
Reply with quote
shalimar
GURU


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

PostPosted: Thu Jun 28, 2018 6:54 pm   
 
First thing I notice is that you have introduced a static variable (@recipeName) to use instead of the local variable ($name), yet you did not adjust the value in the function %db to match.
Second, #PROMPT is great for setting static variables, but you need %prompt for the local variables.

Try to avoid using static variables for any purpose where the value will have no use in any other setting.

Try it more like:

$name=%prompt("", "Enter the name of the recipe.")
$this=%db(@RecipeResearch,$name)
#ADDKEY $this Ginseng %prompt("", "How many ginseng are used in this recipe?")

Though I would suggest saving the value to a local variable before using it in commands, it is quite possible to skip that step entirely.

The only other issue i see is with your math.
Namely, the lack of parenthesis...
And the use of static variables which may no longer match up with the recipe being used, especially since if we know what was cooked, we can just as easily reference the value we need from the database.

In this scenario I would go with #RAISEing an #EVENT.

#EVENT onCooked {
$name=%params
$this=%db(@RecipeResearch, $name)
Ginseng = (@Ginseng - $this.Ginseng)
Thyme = (@Thyme - $this.Thyme)
Nightshade = (@Nightshade - $this.Nightshade)
Tigerroot = (@Tigerroot - $this.Tigerroot)
Hemlock = (@Hemlock - $this.Hemlock)
Sage = (@Sage - $this.Sage)
Wolfsbane = (@Wolfsbane - %db($this, "Wolfsbane"))
}

You just need to find a way to figure out what you just created, either from the MUD, or your own variable to pass on the command:

#TR {You did it!} {#RAISE onCooked "Some Recipe"}
#TR {You cooked a (*)!} {#RAISE onCooked %1}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Thu Jun 28, 2018 9:24 pm   
 
yea I see your point on the linking the deduction from recipe onConcoct as opposed to the alias for recipe. The whole DB thing is new to me and I'm still trying to wrap my head around it.

Thanks for the assistance.

OK, IF I understood your advice...
Code:
// Create recipe
$name=%prompt("", "Enter the name of the recipe.")
$this=%db(@RecipeResearch,$name)
#ADDKEY $this Ginseng %prompt("", "How many ginseng are used in this recipe?")
#ADDKEY $this Thyme %prompt("", "How many ginseng are used in this recipe?")
#ADDKEY $this Nightshade %prompt("", "How many thyme are used in this recipe?")
#ADDKEY $this Tigerroot %prompt("", "How many tigerroot are used in this recipe?")
#ADDKEY $this Hemlock %prompt("", "How many hemlock are used in this recipe?")
#ADDKEY $this Sage %prompt("", "How many sage are used in this recipe?")
#ADDKEY $this Wolfsbane %prompt("", "How many wolfsbane are used in this recipe?")

recipe $name $this.Ginseng $this.Thyme $this.Nightshade $this.Tigerroot $this.Hemlock $this.Sage $this.Wolfsbane

// Craft recipe, consume sample, record results
cct $name
vial $name
#SENDRAW {!score}
#WA 2000

// Add to database the captured stat bonuses
#ADDKEY $this STR @bonusStrength
#ADDKEY $this CON @bonusConstitution
#ADDKEY $this INT @bonusIntelligence
#ADDKEY $this WIS @bonusWisdom
#ADDKEY $this DEX @bonusDexterity
#ADDKEY $this QUI @bonusQuickness


Code:
#REGEX {^You mix up your herbs together and grind them up. Adding water, you begin to concoct a vial of (\w+).$} {
#RAISE onConcoct %1
}

#EVENT {
$name=%params
$this=%db(@RecipeResearch, $name)
Ginseng = (@Ginseng - $this.Ginseng)
Thyme = (@Thyme - $this.Thyme)
Nightshade = (@Nightshade - $this.Nightshade)
Tigerroot = (@Tigerroot - $this.Tigerroot)
Hemlock = (@Hemlock - $this.Hemlock)
Sage = (@Sage - $this.Sage)
Wolfsbane = (@Wolfsbane - $this.Wolfsbane)
}
Reply with quote
shalimar
GURU


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

PostPosted: Fri Jun 29, 2018 4:25 am   
 
Not sure what your 'recipe' command there is doing, but it looks redundant.
Also, you are not plugging $this back into your database after defining it:

#ADDKEY RecipeResearch $name $this

Also, you forgot to name the event there, but otherwise, it looks good
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Fri Jun 29, 2018 4:51 am   
 
Ah. That might be why it's not working as expected. redundancy removed, added the plugging in. and event was created with the name used from trigger's #RAISE.

ok, that did add the recipe. but not the stat mods.... nm added the plugging in to that section fixed that.
but without the recipe line it doesn't seem to want to actually create the recipe. having it in there does. wierd

Final question... is there a way to output this to a file/log
using to this to verify each entry...but it doesn't show the name, just everything else.

#SHOW %dbvalues(@RecipeResearch) I want to be able to show Name : Values of 'name'
Reply with quote
shalimar
GURU


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

PostPosted: Fri Jun 29, 2018 1:06 pm   
 
I'm assuming the recipe line is the original alias.
But I got the impression you had made another alias where it is prompting you for values instead of having them all fed into the system at once. Both methods will work.

As for the database dump, try something like:

#SHOWDB @RecipeResearch

Though this might be more legible:

#FORALL %dbkeys(@RecipeResearch) {
#SAY <color red>%i</color>
#SHOWDB @RecipeResearch.%i
}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Sat Jun 30, 2018 2:56 am   
 
Is it possible to nest entries ?

an example of my desire... main entry Name with three Keys Recipe, Bonus, SideEffect and those having their own Key/Values ?

GI1:
Recipe: Ginseng=1|Thyme=0|Nightshade=0|Tigerroot=0|Hemlock=0|Sage=0|Wolfsbane=0|
Bonus: STR=+ 2|CON= 0|INT= 0|WIS=+ 2|DEX= 0|QUI=+ 4|
SideEffect: STR=- 2|CON= 0|INT= 0|WIS=- 2|DEX= 0|QUI=- 4
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Sun Jul 01, 2018 9:57 pm   
 
OK, I've made a couple changes. Now using 3 databases RecipeResearch, BonusesResearch, SideEffectResearch

the first is with the main alias used to create the recipe and adjust the stockpile tracking (which technically has no real importance here.)

the other two are triggered on when i consume the concocted recipe as well as when it is no longer in effect.
resulting in...
Code:
GI01: Ginseng=1|Thyme=0|Nightshade=0|Tigerroot=0|Hemlock=0|Sage=0|Wolfsbane=0

GI01: STR=+ 2|CON=  0|INT=  0|WIS=+ 2|DEX=  0|QUI=+ 4

GI01: STR=  0|CON=  0|INT=  0|WIS=  0|DEX=  0|QUI=  0


I would like to combine all this to a single database like so...
Code:

GI01: Recipe: Ginseng=1|Thyme=0|Nightshade=0|Tigerroot=0|Hemlock=0|Sage=0|Wolfsbane=0|Bonuses: STR=+ 2|CON=  0|INT=  0|WIS=+ 2|DEX=  0|QUI=+ 4|Side-Effects: STR=  0|CON=  0|INT=  0|WIS=  0|DEX=  0|QUI=  0


but I can't figure out how to do so. If possible each step could add it's portion to the final database, they each have the Name portion in common.

thanks in advance.


Last edited by chaossdragon on Tue Jul 03, 2018 2:03 pm; edited 1 time in total
Reply with quote
shalimar
GURU


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

PostPosted: Tue Jul 03, 2018 3:20 am   
 
Seems like the side effects are the bonuses from here, so i am having trouble seeing why they need to have double entries.
Perhaps you could show me an example of how they differ?
It's a semantical issue really.

Ideally, you would want it to be referencing: @RecipeResearch.GI01.STR

Your proposal would be referencing: @RecipeResearch.GI01.Bonus.STR
Which means adding at least three extra lines of code, and two local variables (for each level of depth) for your getters and setters.

$type=??
$that=%db($this, $type)
#ADDKEY $this $type $that
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Tue Jul 03, 2018 6:00 am   
 
so far the basic stuff i have researched don't have many if any side effects. its the more complex recipes that will have more dramatic negatives. the sample i posted was just to get an idea of how I want it to look.

if i can get a basic format going I can then post the research to the muds wiki

but if i could just reference the recipe by name to look it up that would be awesome. so I can then copy/paste that to the wiki directly... unless i can actually export it to a file i can then upload.

https://1drv.ms/t/s!AhMgRb1DtUIms0WPNk-KoN8lNoL_ (sample of actual in-game results... manually edited to this layout)

upon reflection, I could just have my 'dbcheck <arg>' alias #SHOW Recipe <output of DB>, #SHOW Bonuses <output of DB>, #SHOW Side-Effects <output of DB>

saving me from having to use the extra lines.
Reply with quote
shalimar
GURU


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

PostPosted: Tue Jul 03, 2018 7:25 pm   
 
So for a given segment, it would be like this:

Code:
$name=%prompt for of pass name
$recipe=%db(@RecipeResearch, $name)
$type=use a %pick to select between valid types, or pass value
$this=%db($recipe, $type)
#ADDKEY $this Stat Value
//repeat line above till all that needs assigning, is
#ADDKEY $recipe $type $this
#ADDKEY RecipeResearch $name $recipe


and the alias would be

Code:
#ALIAS dbcheck {
  #FORALL %dbkeys(@recipeResearch) {
    $recipe=%db(@recipeResearch, %i)
    #IF (%1) {
      $type=%1
      $this=%db($recipe, $type)
      #SAY $type of %i
      #SHOWDB $this
      } {
      #FORALL %dbkeys($recipe) {
        $this=%db($recipe, %j)
        #SAY %j of %i
        #SHOWDB $this
        }}}}
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Wed Jul 04, 2018 2:16 pm   
 
ok, last thing And I believe this is falling into the realm of you warned me about this point.

the stockpile tracking onEvent you recommended I use.
Code:
$name=%params
$this=%db(@RecipeResearch, $name)
Ginseng = (@Ginseng - $this.Ginseng)
Thyme = (@Thyme - $this.Thyme)
Nightshade = (@Nightshade - $this.Nightshade)
Tigerroot = (@Tigerroot - $this.Tigerroot)
Hemlock = (@Hemlock - $this.Hemlock)
Sage = (@Sage - $this.Sage)
Wolfsbane = (@Wolfsbane - $this.Wolfsbane)


is now clearing all value from my stockpile. I'm assuming I need to fix the $this portion to reflect the addition of the 'Recipe' sub-type from the above post.
Reply with quote
shalimar
GURU


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

PostPosted: Wed Jul 04, 2018 2:45 pm   
 
Correct
$this=%db(%db(@RecipeResearch, $name), "Recipe")
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Wed Jul 04, 2018 2:56 pm   
 
Thank you so much. This is working perfectly so far. now to just sit here for hours on end and run the gambit of research for all the concoctions I can think of. lol
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