Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Mudlet Scripting

145791018

Comments

  • SaitouSaitou Member Posts: 20
    Okay so I've been trying to set up a script to suggest a hypnosis and then move onto the next hypnosis in my priority list. The problem I have is that it just keeps suggesting the first hypnosis in my list. This is my code:

    function AssassinHypnosis()


    local nextHypnosis = combat.priority.hypnosis.lock or combat.priority.hypnosis.remove("lock", 1)


    send("suggest "..dabomb.target.." "..getAffHypnosis(nextHypnosis[1]))

    end


    image
  • IluvIluv Member Posts: 703 ✭✭✭✭
    edited March 2014
    SCRIPT:

    hypnoadded = hypnoadded or 1

    Hypnosislockqueue = {"Impatience","Epilepsy","Hypochondria","Heroism","Deadening"}

    TRIGGER:

    ^You issue the suggestion of impatience, concealing it deep within (\w+)'s mind\.$

    if (hypnoadded > #Hypnosislockqueue) then

    hypnoadded = 1

    else

    hypnoadded = hypnoadded + 1

    end


    Alias:

    suggest " .. target.name .. " " .. Hypnosislockqueue[hypnoadded]
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    Without referencing Nyoka's code, I would guess this was also a problem:

    combat.priority.hypnosis.remove("lock", 1)

    It probably would be:

    combat.priority.hypnosis:remove("lock",1)

    Although I suspect that too would not be entirely correct.
    wit beyond measure is a Sidhe's greatest treasure
  • KalonKalon Member Posts: 124 ✭✭✭
    Saitou said:

    Okay so I've been trying to set up a script to suggest a hypnosis and then move onto the next hypnosis in my priority list. The problem I have is that it just keeps suggesting the first hypnosis in my list. This is my code:

    function AssassinHypnosis()


    local nextHypnosis = combat.priority.hypnosis.lock or combat.priority.hypnosis.remove("lock", 1)


    send("suggest "..dabomb.target.." "..getAffHypnosis(nextHypnosis[1]))

    end

    First, awesome on you for encapsulating your variable names in namespaces, using local variables, and abstracting out into a function instead of just dropping the code right in a script.

    It looks like the problem is the assignment to nextHypnosis -- I suspect the second half of the logical extension is never firing, or if it is, its not removing anything, because you've already asserted that the thing you're trying to remove does not exist.

    Mind demonstrating what the data structure stored in combat.priority.hypnosis looks like? Also possibly the definition for getAffHypnosis(), if its not just a one liner mapping priority.hypnosis to aff names I'll be able to offer slightly more targeted help if I know those things.
  • GabrielGabriel Member Posts: 89 ✭✭
    Converting to Mudlet. I'm utterly inept right now.
    I'm trying to set up a trigger to tell my system that I'm off balance. I'm trying to use the: Balance Taken: 4.7s line as the trigger.

    I've tried ^Balance Taken: (\d+)s  ^Balance Taken: (\w+)  ^Balance Taken: (\d+)(\w+)

    Nothing gets it to recognize that line.
    image
  • MereisMereis Member Posts: 229 ✭✭✭
    edited March 2014
    You may want to use:

    ^Balance Taken\: (\d+)\.(\d+)s$

    Punctuations like : and . usually need to be preceeded by a \ so that they won't be considered as variables (rather, they'll be considered as part of the actual regex trigger).

    Edit:

    You can also do
    ^Balance Taken\: (.*)s$

    (.*) captures any character (so it would capture 4.7 as "4.7", rather than the previous trigger which would capture 4.7 as "4" and "7").


    currently tentatively active
    (may vanish for periods of time)
  • KhizanKhizan Member Posts: 2,648 ✭✭✭✭✭
    edited March 2014

    Explanation: 

    • (\d+) : Capture one or more digits 0-9.
    • (\w+) : Capture one or more word characters. Generally speaking, this is a-z, A-Z, 0-9, and the underscore character
    • (\d)(\w+) : Capture one or more digits in one variable(eg: $1) and then capture one or more word characters in a separate variable(eg: $2)

    The one thing all those patterns have in common is that they fail to account for the '.' in the number. You have to remember, regex doesn't consider "1.2" to be a floating point number; it sees characters without context. '1' is a number, '.' is a period and not part of a number, '2' is a number. And so "(\d+)s" does not match "1.2".

    The pattern I would probably use is:

    (\d+\.\d+) : Capture one or more digits, a period, and one or more digits. The period has to be represented as '\.' because '.' means "any character". The backslash escapes the special meaning of the period, making it just a character.

    "On the battlefield I am a god. I love war. The steel, the smell, the corpses. I wish there were more. On the first day I drove the Northmen back alone at the ford. Alone! On the second I carried the bridge! Me! Yesterday I climbed the Heroes! I love war! I… I wish it wasn’t over."

  • FyraineFyraine Member Posts: 23
    You might find this site useful
    regexpal.com
    for testing your patterns.

    If you paste the test line in first, and then type in the regex, you can see it being highlighted yellow (indicating that the pattern is being matched) as you go, and it becomes pretty obvious the moment you make a mistake.

    Incidentally, unless you're specifically trying to capture the balance loss number for something (cooldown timers maybe?) then there is no need to make that trigger a regular expression.

    Choose "Begin of line substring" as the trigger type, and "Balance Taken:" as the pattern.


  • GabrielGabriel Member Posts: 89 ✭✭
    Thanks everyone! I can actually put all of those suggestions to good use in a lot of ways.

    I'll pester folks in clans and such as much as I can, but I'm pretty sure I'll be burning up this forum thread a good bit too.

    Forgive me in advance.
    image
  • SaitouSaitou Member Posts: 20
    This shadowplant script is seriously going to drive me INSANE. Why is it telling me he eats a shadowplant when he eats a hyssop when I shadowplanted kelp?!?!?!?!?!

    Your aura of weapons rebounding disappears.
    (Defense): Lost Antiweaponfield
    You rub some hemotoxin on a needle-pointed dirk.
    Weapon: [VENOM  : HEMOTOXIN]
    Weapon: [VENOM  : HEMOTOXIN]
    You prick Mereis quickly with your dirk.
    CombatSystem: [ENEMY AFFLICTED WITH HEMOTOXIN]
    Mereis pales suddenly and slumps perceptibly.
    You rub some oxalis on a needle-pointed dirk.
    Weapon: [VENOM  : OXALIS]
    Weapon: [VENOM  : OXALIS]
    Maintaining your balance, you deftly prick Mereis again.
    CombatSystem: [ENEMY AFFLICTED WITH BLIND]
    Balance Taken: 2.80s
    Health:105 Mana:352 (e-)
    You force a small opening in your wormhole and a shadowy replica of a piece of kelp pops out of it
    and lands in Mereis's hands.
    SHADOWPLANT: KELP
    Equilibrium Taken: 2.80s < equilibrium >
    Health:105 Mana:342 (--)
    Mereis takes a drink from a simple isan vial.
    Health:105 Mana:342 (--)
    Mereis quickly eats a piece of kelp. Person ate a kelp
    CombatSystem: ENEMY CURED HEMOTOXIN (herb/slice)
    Mereis's colour returns to her face.
    Health:105 Mana:342 (--)
     < linseed pipe > ( 5 left )
    Health:105 Mana:342 (--)
    You may drink another healing elixir. ( sipped )
    Health:105 Mana:342 (--)
    You find an elixir of mana too irresistible and drink it instead.
    You take a drink of an elixir of mana from a wooden vial. < sipped >
    Your mind feels rejuvenated.
    Health:105 Mana:371 (--)
    A small black cobra's hood flares as it darts forward to bite Mereis.
    Health:105 Mana:371 (--) ds;kk
    lua AssassinVenom()
    order loyals attack Mereis
    dstab Mereis hemotoxin mercury
    worm shadowplant Mereis kelp
    You feel a sudden disturbance and pain floods you as you watch the residual light from the flash.
    Damage Taken: 42 magickal, mental (raw damage: 47)
    [Affliction]: You have Epilepsy
    Health:63 Mana:371 (--)
    You may eat another herb or plant. ( herb )
    Health:63 Mana:371 (--)
    You quickly eat a wormwood root. < herb >
    Your terrible addiction to lovely elixirs seems to wane.
    [Affliction] Cured: Addiction
    Health:63 Mana:371 (--)
    Mereis quickly eats some hyssop stem. Person ate a hyssop
    SHADOWPLANT EATEN


    This is my setup:

    Trigger: ^You force a small opening in your wormhole and a shadowy replica of a piece of kelp pops out of it and lands in .+ hands.$

    shadowplanted = false

    shadow = "shadownone"

    if plantedtimer then killTimer(plantedtimer) end

    plantedtimer = tempTimer(1, [[shadowplanted = true]])

    if shadowtimer then killTimer(shadowtimer) end

    shadowtimer = tempTimer(1, [[shadow = "shadowkelp"]])

    if plantedtimer1 then killTimer(plantedtimer1) end

    plantedtimer1 = tempTimer(4, [[shadowplanted = false]])

    cecho("<orange_red>\nSHADOWPLANT: KELP")


    Trigger: ^.+ quickly eats a piece of kelp.$

    if shadowplanted == true and shadow == "shadowkelp" then

    shadowplanted = false and killTimer(plantedtimer1)

    end


    Cure Tracking Script:


    function TrackSlice(name)

    if combat.afflictions.paralysis and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.sensitivity and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.numbness and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.slickness and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.frostbite and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.limbparalysis and shadowplanted == true

    and shadow == "shadowmaidenhair" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.asthma and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.hemotoxin and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.butisol and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.clumsiness and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.weakness and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.attunedtowater and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.healthleech and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.rigidity and shadowplanted == true

    and shadow == "shadowkelp" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.sunallergy and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.nausea and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.lethargy and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.attunedtoearth and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.haemophilia and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.burningnerves and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.dryblood and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.recurringfreezing and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.sulfonal and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    elseif combat.afflictions.tainattunement and shadowplanted == true

    and shadow == "shadownightshade" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")

    else

    for _,v in ipairs(tarcuringorder[name]) do

    if combat.afflictions[v] then

    combat.afflictions[v] = false

    combat.afflictions.anorexia = false

    echo("\nCombatSystem: ENEMY CURED " .. string.upper(v) .. " (herb/slice)")

    enemyAffshow()

    return

    end

    end

    end

    end



    What am I doing wrong?


    image
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    You're also triggering this: Mereis quickly eats some hyssop stem. Person ate a hyssop What is the code associated with that trigger?
    wit beyond measure is a Sidhe's greatest treasure
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    More importantly, your TrackSlice should compare what is eaten (I'm guessing that's the 'name' argument) with the shadow plant type, for accuracy's sake. Something like, if ... And ... And ... And "shadow"..name == shadow then
    wit beyond measure is a Sidhe's greatest treasure
  • SaitouSaitou Member Posts: 20
    edited April 2014
    I don't have a trigger for eating hyssop which is why I don't understand why its triggering the shadowplant.

    So I should do something like this?

    Trigger: ^.+ quickly eats a piece of kelp.$

    herb = "kelp1"


    if shadowplanted == true and shadow == "shadowkelp" then

    shadowplanted = false and killTimer(plantedtimer1)

    end


    Then for Trackslice:


    elseif combat.afflictions.asthma and shadowplanted == true

    and shadow == "shadowkelp" and herb == "kelp1" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")


    Post edited by Saitou on
    image
  • SaitouSaitou Member Posts: 20
    There's also this:

    ^(\w+) quickly eats (some|an|a) (.+)\.$

    local sub_eherb = {

    ["galingale flower"] = "galingale",

    ["hyssop stem"] = "hyssop",

    ["juniper berry"] = "juniper",

    ["piece of kelp"] = "kelp",

    ["maidenhair leaf"] = "maidenhair",

    ["mandrake root"] = "mandrake",

    ["nightshade root"] = "nightshade",

    ["orphine seed"] = "orphine",

    ["wormwood root"] = "wormwood",

    }



    if table.contains(sub_eherb, matches[4]) then

    local eherb = sub_eherb[matches[4]]

    cecho(" <yellow>Person ate a " .. sub_eherb[matches[4]])

    TrackSlice(eherb)

    end


    end


    If that has anything to do with it?


    image
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    There's your hyssop that's triggering the shadow plant.
  • SaitouSaitou Member Posts: 20
    How is it triggering the shadowplant?
    image
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    ^(\w+) quickly eats (some|an|a) (.+)\.$ is triggering on the hyssop and calling TrackSlice. You didn't have a check in TrackSlice to see if the herb matched the shadow plant.
  • SaitouSaitou Member Posts: 20
    I added that extra check in there

    elseif combat.afflictions.asthma and shadowplanted == true

    and shadow == "shadowkelp" and herb == "kelp1" then

    cecho("<orange_red>\nSHADOWPLANT EATEN")


    and it just stopped working completely.


    image
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    I assume that one of those didn't evaluate to true.

    Try echoing the values locally so you can check them. Or use the lua alias to check them.
  • SaitouSaitou Member Posts: 20
    You're right. My shadowplant trigger was setting shadow to "shadownone" instead of "shadowkelp" or whichever herb it was. I'll test it in a few to see if that fixed it.
    image
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    edited April 2014
    I think you are setting the herb to 'kelp' but trying to match it as 'kelp1'.
  • SaitouSaitou Member Posts: 20
    Well I originally had it as "kelp1" because I thought "kelp" was interfering with something but I switched everything to just "kelp"
    image
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    The other thing i'd do is also echo what type of shadow plant is consumed, at least in the initial stages
    wit beyond measure is a Sidhe's greatest treasure
  • SaitouSaitou Member Posts: 20
    So I added these checks to each herb....

      You force a small opening in your wormhole and a shadowy replica of a maidenhair leaf pops out of it and lands in .+ hands.
     
    shadowplanted = false
    shadow = "shadowmaidenhair"
    herb = "maidenhair"
    if plantedtimer then killTimer(plantedtimer) end
    plantedtimer = tempTimer(1, [[shadowplanted = true]])
    if shadowtimer then killTimer(shadowtimer) end
    shadowtimer = tempTimer(1, [[shadow = "shadowmaidenhair"]])
    if plantedtimer1 then killTimer(plantedtimer1) end
    plantedtimer1 = tempTimer(4, [[shadowplanted = false]])
    cecho("<orange_red>\nSHADOWPLANT: MAIDENHAIR")


    and then

    if combat.afflictions.paralysis and shadowplanted == true
                                            and shadow == "shadowmaidenhair" and herb == "maidenhair" then
                            cecho("<orange_red>\nSHADOWPLANT EATEN")
                                            elseif combat.afflictions.sensitivity and shadowplanted == true
                                            and shadow == "shadowmaidenhair" and herb == "maidenhair" then
                                                         cecho("<orange_red>\nSHADOWPLANT EATEN")

    but its still triggering off other herbs than the one shadowplanted.

    image
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    http://pastebin.com/h5rrJK6c

    I'm sleepy and haven't tested it so… use with caution :)
    wit beyond measure is a Sidhe's greatest treasure
  • CassiusCassius Member, Beta Testers Posts: 607 ✭✭✭
    Sleepy Iniar....I think you need to check the 'name' passed in TrackSlice to the herb shadowplanted.  Unless I missed it in there.
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    edited April 2014
    Oh I made a big booboo in that one but my face is too tired to try and fix it :D and you're right Cassius I need to do something like.. And shadowplanted == name then
    wit beyond measure is a Sidhe's greatest treasure
  • SaitouSaitou Member Posts: 20
    a big booboo?!
    image
  • IniarIniar Member Posts: 3,213 ✭✭✭✭✭
    We kinda fixed it already :(
    wit beyond measure is a Sidhe's greatest treasure
  • SaitouSaitou Member Posts: 20
    Oh, yeah I added shadowplanted == true and shadowplant == name then
    image
Sign In or Register to comment.