Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Quick Coding Questions

11314151719

Comments

  • VadimusesVadimuses Posts: 1,077Member @ - Epic Achaean
    Nice! Glad to hear 3.5 is working well. Let's get more people on it!
  • DochithaDochitha Posts: 1,283Member @ - Epic Achaean
    So I am trying to match the room name from line, say:

    The Motley Magpie (indoors).
    Centre Crossing.

    How do I only get the room name and not the (indoor) or (indoor roads) bit?

    Thanks.
  • AhmetAhmet Wherever I wanna bePosts: 3,370Member @@ - Legendary Achaean
    mmp.cleanroomname(blah)
    Huh. Neat.
    Dochitha
  • AntoniusAntonius Posts: 4,499Member @@ - Legendary Achaean

    Is there a function to select or deselect a specific variable on the Variables window so that I don't have to do it manually?

  • VadimusesVadimuses Posts: 1,077Member @ - Epic Achaean
    Not at the moment, just the table.save() and table.load() functions.
  • DevranDevran Posts: 544Member ✭✭✭✭ - Eminent
    Can anyone tell me how I can make Keneanaung, the bashing system, use Jinx Bleed Bleed when I have Malign power as a Shaman? (Which is after every normal Swiftcurse Bleed basically so it goes Curse Bleed, Jinx Bleed bleed, Curse bleed, etc.)

    I've tried 'kconfig bashing attackcommand jinx bleed bleed &tar/swiftcurse &tar bleed' to set the custom alias to try and make it use Jinx every balance and when it fails, just swiftcurse, but no luck. 

    I'm terrible at Mudlet. Help?
  • AntoniusAntonius Posts: 4,499Member @@ - Legendary Achaean
    You don't get Jinx charges from Swiftcurse, as far as I know. You would need to be using regular curse bleed.
    Devran
  • DevranDevran Posts: 544Member ✭✭✭✭ - Eminent
    edited November 2017
    Antonius said:
    You don't get Jinx charges from Swiftcurse, as far as I know. You would need to be using regular curse bleed.
    Hrm. You could be entirely right. I can't say for sure, because I was using the blank KILL alias which was using Curse Bleed, but SVO was keeping SWIFTCURSE up, and I was getting it every second balance.

    I don't know?\

    EDIT: According to in game sources, having Swiftcurse up wont interfere with this.

    Now to just find out how to make Keneanaung do it.
  • SolnirSolnir Posts: 709Member ✭✭✭✭✭ - Grand Achaean
    Swiftcurse doesn't proc jinx charges. So if you're using swift, you won't get to use jinx at all.
    Devran
  • DevranDevran Posts: 544Member ✭✭✭✭ - Eminent
    Solnir said:
    Swiftcurse doesn't proc jinx charges. So if you're using swift, you won't get to use jinx at all.
    You're correct! It wasn't swiftcursing.
  • DevranDevran Posts: 544Member ✭✭✭✭ - Eminent
    I figured it out! It was something simple. I just had to change the original command I tried to 'kconfig bashing attackcommand jinx bleed bleed &tar/curse &tar bleed' instead of trying to use swiftcurse. 

    I thought I'd tried that. Apparently I hadn't. Derp.

    Thanks for the advice folks. :)
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    can anyone tell me why this is not working at all?

    venom1 = loki
    venom2 = delphinium
    venom3 = loki
    if juggling == true then 
    send("queue add eqbal throw axe at " .. target .." ".. venom1 ..";queue add eqbal throw axe at " .. target .." "..venom2..";queue add eqbal throw axe at " .. target .." "..venom3)
    elseif juggling == nil then
    send("unwield left;queue add eqbal juggle axe axe axe;queue add eqbal throw axe at " .. target .." "..venom1..";queue add eqbal throw axe at " .. target .." "..venom2..";queue add eqbal throw axe at " .. target .." "..venom3)
    end

    worked fine until I started throwing the venoms with variables in there.
  • AtalkezAtalkez Posts: 4,691Member @@ - Legendary Achaean
    Well you can’t envenom Loki, so that could be an issue. 


    You hug Aurora compassionately.
  • AlyxeriAlyxeri Posts: 467Member ✭✭✭✭ - Eminent
    Dominius said:
    can anyone tell me why this is not working at all?

    venom1 = loki
    venom2 = delphinium
    venom3 = loki
    if juggling == true then 
    send("queue add eqbal throw axe at " .. target .." ".. venom1 ..";queue add eqbal throw axe at " .. target .." "..venom2..";queue add eqbal throw axe at " .. target .." "..venom3)
    elseif juggling == nil then
    send("unwield left;queue add eqbal juggle axe axe axe;queue add eqbal throw axe at " .. target .." "..venom1..";queue add eqbal throw axe at " .. target .." "..venom2..";queue add eqbal throw axe at " .. target .." "..venom3)
    end

    worked fine until I started throwing the venoms with variables in there.
    Need to wrap variable values in "" in this instance.

    venom1 = "loki"
    venom2 = "delphinium"
    venom3 = "loki"

    but yes as Atalkez said, can't envenom loki anyway.
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    Ahh, no it wasn't cause of the loki, that was just random, the quotation marks did the trick, anyone able to explain why? Things have been working without them for me for a long time..
  • AntoniusAntonius Posts: 4,499Member @@ - Legendary Achaean
    It's a difference in data types. If you have the quotes, you're saying everything between them is a string (a piece of literal text). "loki" is a string containing the word loki.

    Without the quotes, you're saying it's a variable with that name. loki is a variable called loki, and its value can be anything (or nothing at all if the variable doesn't actually exist).

    In other words, venom1 = "loki" sets the value of the variable venom1 to the word loki. venom1 = loki sets the value of the variable venom1 to the value of the variable loki. Unless you've done loki = <something> at some point you're actually not setting venom1 to anything.
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    So many things all the sudden make so much sense, thanks @Antonius
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    Ok, I hope this is the right place to ask I know next to nothing about coding. I am trying to make a script to select needed venoms for me since I am unable to keep up with the speed manually. I am jester juggling 3 things and I need 3 venoms selected, so far this has been working but I am still uneasy about putting in venom2 and venom3:

    function venomprioasthma ()
       if affstrack.score.asthma<100 then
    venom1 = "kalmia"
    elseif affstrack.score.asthma>66 and 
    affstrack.score.anorexia<100 then
          venom1 = "slike"
       elseif affstrack.score.asthma>66 and
    affstrack.score.anorexia>66 and
    affstrack.score.paralysis<100 then
          venom1 = "curare"
       elseif affstrack.score.asthma>66 and
    affstrack.score.anorexia>66 and
    affstrack.score.paralysis>66 and
    affstrack.score.slickness<100 then
          venom1 = "gecko"

    appreciate any help on making this a bit simpler for venom2 and venom3 because they basically need to do whatever comes after venom1 having asthma being the priority affliction I want to give my target. If any jesters out there need help I can make this public once I have it working.
  • JacenJacen Posts: 2,302Member @@ - Legendary Achaean
    How about something like this?
    local venoms = {}
    local affVenomPrio = {
        {"asthma", "kalmia"},
        {"anorexia", "slike"},
        {"paralysis", "curare"},
        {"slickness", "gecko"}
    }
    local i = 0
    
    for _,v in pairs(affVenomPrio) do  -- for each affliction/venom in order
        if affstrack.score[v[1]] < 100 then -- if aff is < 100, choose that venom
            venoms[i] = v[2]
            i = i + 1
            if i > 3 then break end -- once we've gotten 3 venoms, we're through
        end
    end
    
    Main thing to note is this puts your venoms in venoms[1], venoms[2], venoms[3], instead of venom1, venom2, venom3.
    image
  • TaryiusTaryius Posts: 409Member ✭✭✭✭ - Eminent
    Reading these last two comments really hammers in my lack of coding skills. I understood what @Dominius was doing but as soon as @Jacen took a spin on it I couldn't understand anything. No clue what 80% of that code means, what it does, or how it does it. :frown:
  • VadimusesVadimuses Posts: 1,077Member @ - Epic Achaean
    It's been suggested that I make a video on using tables which is what Jacen is doing there - I'll get around to it. Meanwhile, maybe you can learn something from this: 
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    That really does look awesome @Jacen, maybe you can PM me letting me know what that actually does? I read through the manuals a lot, but it's largely time consumingand being very busy in general breaking it down would help immensely
  • JacenJacen Posts: 2,302Member @@ - Legendary Achaean
    Jacen said:
    How about something like this?
    local venoms = {}
    local affVenomPrio = {
        {"asthma", "kalmia"},
        {"anorexia", "slike"},
        {"paralysis", "curare"},
        {"slickness", "gecko"}
    }
    local i = 0
    
    for _,v in pairs(affVenomPrio) do  -- for each affliction/venom in order
        if affstrack.score[v[1]] < 100 then -- if aff is < 100, choose that venom
            venoms[i] = v[2]
            i = i + 1
            if i > 3 then break end -- once we've gotten 3 venoms, we're through
        end
    end
    
    Main thing to note is this puts your venoms in venoms[1], venoms[2], venoms[3], instead of venom1, venom2, venom3.
    local venoms = {}
    Starts a new, local, empty table named venoms. The local part means that the variable venoms is local to this scope. That is to say, if you try to check the value of venoms outside this particular script, it will not exist.

    A Lua table is a object that has keys and values, such that table[key] = value. Its like going to the post office with a PO Box number. With the PO Box number (key) you can open the box and see what's inside (value). Its important to note that in Lua, keys and values don't have to be numbers. They can be just about anything in Lua, but most usually are numbers or strings (i.e table["Telephone Number"] = 8675309) 
    local affVenomPrio = {  
        {"asthma", "kalmia"},
        {"anorexia", "slike"},
        {"paralysis", "curare"},
        {"slickness", "gecko"}
    }
    This makes a new, local, non-empty table affVenomPrio. The keys for this table are implicit (I didn't specify them), which in Lua, means they start numbering from 1. So, affVenomPrio[1] = {"asthma, "kalmia"}. The implicit key 1 is mapped to the value of {"asthma, "kalmia"} A table inside a table! I made this table so that I could associate afflictions with venoms (i.e. when I checked affstrack.score.affliction, I would know what the venom associated with that affliction was). 
    The main reason I made the keys of this table implicit, which numbered them from 1 to the length of the table, was that it would impose an order on the table. Now the first thing I check is affVenomPrio[1], then second will be affVenomPrio[2], and so on. I can change the priority of afflictions by changing the order of the table.
    local i = 0
    Simply a counter for us to track how much of our venoms table we've filled up. This is actually totally unnecessary, as there's a different way to accomplish the same thing, but hopefully this makes the code a little more clear. i represents how many venoms we're calculating, and when we reach that limit, we stop!
    for _,v in pairs(affVenomPrio) do  -- for each affliction/venom in order
    This is the most complicated line of the code, so bear with me. The pairs function is a native Lua function that iterates over the keys and values of a table. Step by step, this function is going to return the next key and its value. For example, at one point it will return 3{"paralysis", "curare"}. We store those results in the local variables _, v

    _, v is interesting because of the underscore. And underscore in Lua means that we know there's something there, but we don't care about it. In this case, we know that the pairs() function is returning a key there, but we don't care about it, so we immediately throw it out. We only care about the value portion, which is going to be stored in the variable v.

    if affstrack.score[v[1]] < 100 then -- if aff is < 100, choose that venom
    This line checks the score of an affliction. Remember v is the value of a key from our table. Its going to hold things like {"asthma", "kalmia"}. The snipped v[1] checks the first element of v. In this case, it would return the string "asthma" . The table affstrack.score is an example of a table that has non-number keys. The keys of this table are afflictions in the form of strings. We can access the value of these afflictions very similarly to how we accessed the value of element 1 of earlier in this paragraph. Just replace the number with the key string! affstrack.score["asthma"] is a valid call, and will return the number associated with that affliction. 

    To summarize this statement, it says: When given a value v, check the affstrack.score of that value. If its less than 100, then continue

            venoms[i] = v[2]
            i = i + 1
            if i > 3 then break end -- once we've gotten 3 venoms, we're through
    This bit simply says that, if the above if statement is true, then we assign v[2] (which is a venom string, like "kalmia") to the next available slot in our venoms table. Once that's done, we increment so we know we've taken up another slot. Finally, if we've filled up 3 slots of our table, then we're finished! At that point, we break out of our for statement, which takes us to the end of our code!
    image
    Kayle
  • KeneanungKeneanung Posts: 584Member ✭✭✭✭ - Eminent
    edited December 2017
    Jacen said:
    for _,v in pairs(affVenomPrio) do  -- for each affliction/venom in order
    This is the most complicated line of the code, so bear with me. The pairs function is a native Lua function that iterates over the keys and values of a table. Step by step, this function is going to return the next key and its value. For example, at one point it will return 3{"paralysis", "curare"}. We store those results in the local variables _, v

    _, v is interesting because of the underscore. And underscore in Lua means that we know there's something there, but we don't care about it. In this case, we know that the pairs() function is returning a key there, but we don't care about it, so we immediately throw it out. We only care about the value portion, which is going to be stored in the variable v.
    A nice explanation! Just 2 things in this part:
    - pairs does not necessarily run over the table in order. See https://www.lua.org/manual/5.1/manual.html#pdf-pairs and subsequentially https://www.lua.org/manual/5.1/manual.html#pdf-next
    - _ is no special variable or anything. It's just common practice. See https://stackoverflow.com/questions/34475995/variable-in-lua-has-a-special-meaning
  • KeneanungKeneanung Posts: 584Member ✭✭✭✭ - Eminent
    edited December 2017
    And I just noticed another thing that would probably help readability: If you don't use a numbered table for the inner ones, but instead a dictionary, the code would look like this:
    
    
    local venoms = {}
    local affVenomPrio = {
        {
            affliction = "asthma", 
            venom = "kalmia"
        },     {
            affliction = "anorexia",
            venom = "slike"
        },
        {
            affliction = "paralysis",
            venom = "curare"
        },
        {
            affliction = "slickness",
            venom = "gecko"
        }
    }
    
    local i = 0
    for _, affVenomPair in ipairs(affVenomPrio) do  -- for each affliction/venom in order
        if affstrack.score[affVenomPair.affliction] < 100 then -- if aff is < 100, choose that venom
            venoms[i] = affVenomPair.venom
            i = i + 1
            if i > 3 then break end -- once we've gotten 3 venoms, we're through
        end
    end

    I also incorporated my ipairs fix (see above) into this.

    Edit: Formatting is killing me.
  • DaironDairon Posts: 295Member ✭✭✭ - Distinguished
    This might be a stupid question, but what does ipairs do over pairs?
  • KeneanungKeneanung Posts: 584Member ✭✭✭✭ - Eminent
    ipairs goes over a numerically indexed table (where the keys are 1, 2, 3, ...) in order until it reaches the first "gap". pairs iterates over all keys (independent of type and doesn't care about "holes") in undefined order.
    DaironTysandr
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    Ok, so I have tried making a function that is called by an alias that does that exact script and it isn't working. Am I even able to make venom[1] a variable or is the system confused by the [ ]?? What am I missing here?
  • KeneanungKeneanung Posts: 584Member ✭✭✭✭ - Eminent
    From your description, this could be a number of things. If you get an error message, this one would be helpful to know. Also a screenshot of your alias setup and possibly a quote of how you want to use the script help as well.
  • DominiusDominius Posts: 116Member ✭✭✭ - Distinguished
    venomprio()
    send("queue add eqbal throw axe at " .. target .." ".. venoms[1]..";queue add eqbal throw axe at " .. target .." ".. venoms[2]..";queue add eqbal throw axe at " .. target .." ".. venoms[3])

    that's what my alias executes, I tried venom[1] and venoms[1] so far

    I want to use the script to help me make venoms 1- 3 whatever is on top of the list. The affliction tracker is the afftrack.score.affliction bit that decides what to prioritize, does that make sense?
Sign In to Comment.