S&B Combination Script

So, I am trying to build a combination script for S&B, going off of envenoming script I found somewhere for DSLing. Here is what I have so far, and it doesn't work, though my instinct says it's something with the input, but for all I know it could be the entire thing that's wrong.

Could someone help me figure this out, please?


Input:

^d(\w+)(\w+)(\w+)(?: (\w+)|)$
 
Trigger body:
 
limb = nil
venom = nil
shieldArg = nil
 
if venomtree and shieldtree and limbtree then
        venom = venomtree[matches[2]]
        shieldArg = shieldtree[matches[3]]
        if matches[4] then
                limb = limbtree[matches[4]]
                send("combination "..target.." slice "..limb.." "..venom.." smash "..shieldArg)
        else
                send("combination "..target.." slice "..venom.." smash")
        end
else
        venomtree = {
                a       = "aconite",                    --stupidity
                b       = "epseth",                     --shrivel legs
                c       = "curare",                     --paralysis
                d       = "darkshade",          --sunlight allergy
                e       = "delphinium",                 --sleep
                f       = "digitalis",          --shyness
                g       = "gecko",                      --slickness
                h       = "euphorbia",          --vomitting
                i       = "eurypteria",                 --recklessness
                j       = "vernalius",          --weakness
                k       = "kalmia",                     --asthma
                l       = "larkspur",           --dizziness
                m       = "monkshood",          --disloyalty
                n       = "epteth",                     --shivel arms
                o       = "oculus",                     --sight restored
                p       = "prefarar",           --sensitivity
                q       = "notechis",           --haemophilia
                r       = "vardrax",                    --addiction
                s       = "slike",                      --anorexia
                t       = "selarnia",           --animal spirit disruption
                x       = "xentio",                     --clumsiness
        }
        shieldtree = {
                h       = "high",                               --lose focus balance
                m       = "mid",                                --paralysis
                l       = "low",                                --clumsiness
        }
        limbtree = {
                ll      = "left leg",
                rl      = "right leg",
                la      = "left arm",
                ra      = "right arm",
                h       = "head",
                t       = "torso",
        }
        venom = venomtree[matches[2]]
        shieldArg = shieldtree[matches[3]]
        if matches[4] then
                limb = limbtree[matches[4]]
                send("combination "..target.." slice "..limb.." "..venom.." smash "..shieldArg)
        else
                send("combination "..target.." slice "..venom.." smash")
        end
end

Comments

  • edited January 2015
    Try changing the input to ^d(\w)(\w)(\w+)?$ and see if that works.

    There are two problems with the way you have it. First, there are four matches and you only use 3 (and it always expects the third match, for limbs, to be there, only the fourth unused match is optional).
    Second, \w+ matches one or more of any alphanumeric character, and tries to match as much as possible, in order from left to right. So if you tried to do dshrl for stupidity/high/right leg, the first match would be sh, the second match would be r, and the third match would be l, and none of those will be found in the tables.
  • That worked perfectly, thank you for the help and explanation!
  • Related question: (\w\w\w) should match any three letter combination, right?

    Just realized I have some super messy regex I could probably clean up. That jester throwing stuff I wrote at the start of Xith is hilarious, yet functional.

    ^(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)$

    So pro. But (\w\w\w)(\w\w\w)(\w\w\w) would work better and pull from a single venom table just fine.

    His 1-letter venoms make me angry though.
    I like my steak like I like my Magic cards: mythic rare.
  • edited January 2015
    Xith said:
    Related question: (\w\w\w) should match any three letter combination, right?

    Just realized I have some super messy regex I could probably clean up. That jester throwing stuff I wrote at the start of Xith is hilarious, yet functional.

    ^(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)(del|cur|pre|ept|eps|aco|kal|sli|gek|mon|voy|ver|dar|eur|lar|ole|xen|occ|sel|dig|var)$

    So pro. But (\w\w\w)(\w\w\w)(\w\w\w) would work better and pull from a single venom table just fine.

    His 1-letter venoms make me angry though.

    The prototype for my next-gen serpent/apostate/alchemist input system (being worn by some asian guy).

    gz3.jpg 55.2K
  • Xith said:
    Related question: (\w\w\w) should match any three letter combination, right?
    Yes. Or you could do \w{3}
  • We actually have a couple of those caps (or very similar looking ones, at least) in the lab I'm over at school. Haven't got a chance to play with it yet tho. Undergrad is supposed to do some robot formation control with it, should be fun.
    image
  • edited November 2016
    Nevermind.. Ahmet pointed out a STUPID mistake.


  • edited November 2016
    Disregard


  • AhmetAhmet Wherever I wanna be
          
    Huh. Neat.
  • AhmetAhmet Wherever I wanna be
    edited November 2016
    venom = asdf

    should be

    venom = "asdf"

    local a = {
    	xen = "xentio",
    	ole = "oleander",
    	eur = "eurypteria",
    	kal = "kalmia",
    	dig = "digitalis",
    	dar = "darkshade",
    	cur = "curare",
    	ept = "epteth",
    	eps = "epseth",
    	pre = "prefarar",
    	mon = "monkshood",
    	eup = "euphorbia",
    	col = "colocasia",
    	ocu = "oculus",
    	ver = "vernalius",
    	lar = "larkspur",
    	sli = "slike",
    	voy = "voyria",
    	del = "delphinium",
    	var = "vardrax",
    	aco = "aconite",
    	sel = "selarnia",
    	gec = "gecko",
    	scy = "scytherus",
    }
    venom1 = a[matches[2]]
    venom2 = a[matches[3]]
    
    cecho("\n<red> Venom 1: "..venom1)
    cecho("\n<red> Venom 2: "..venom2)

    Huh. Neat.
  • AustereAustere Tennessee
    edited November 2016
    venom1 = "xentio"
    
    Freaking Ahmet beat me to it and stole all the glory. 
  • You also have too many brackets in your alias pattern. Get rid of the first directly after the v and the last directly before the $.
Sign In or Register to comment.