Quick Coding Questions

1101113151624

Comments

  • Does anyone happen to know what the monk stance defense "keepup" variable is for svof? I can't seem to find it. For example, svof's parry variable is "svo.sp_config.parry_shouldbe" 

    [ SnB PvP Guide | Link ]

    [ Runewarden Sparring Videos | Link ]
  • Does anyone happen to know what the monk stance defense "keepup" variable is for svof? I can't seem to find it. For example, svof's parry variable is "svo.sp_config.parry_shouldbe" 
    You can get it from gmcp.Char.Vitals.charstats, iirc.
    string.match(gmcp.Char.Vitals.charstats[3], "Stance: (%w+)")

    Something to that effect, you'll have to change [3] to the right number. No idea about SVO, but that's how you can get what stance you're currently in; can use it to compare to what stance you WANT to be in.

  • Does anyone happen to know what the monk stance defense "keepup" variable is for svof? I can't seem to find it. For example, svof's parry variable is "svo.sp_config.parry_shouldbe" 
    Run -- lua svo.defc -- in command line and see if it returns stances as well? If so you can do if not svo.defc.stancename then do stuff.
  • Stances (and forms) should be normal defenses, that are simply made exclusive to each other. That means they are "svo.defkeepup[svo.defs.mode].<def>", like "svo.defkeepup[svo.defs.mode].eagle".

    Your current stance should be in "svo.me.stance" and "svo.me.form" for tekura and shikudo respectively.
  • Does anyone happen to know how I can get this to fire only when I have dragoncurse/limb/eq balance?

    send("queue addclear eqbal stand~dragoncurse "..target.." paralysis 1~rend " ..target.. " left leg slike~breathgust " ..target)

    [ SnB PvP Guide | Link ]

    [ Runewarden Sparring Videos | Link ]
  • Queue addclear eqbal queue add class the rest of it

  • edited August 2017
    Is there a way to make information stored in a variable fade after x seconds, so it'll be technically empty? For example, direction == matches[2]

    [ SnB PvP Guide | Link ]

    [ Runewarden Sparring Videos | Link ]
  • If you use a timer, you can set it to "nil". Just make sure you kill the timer before you re-set the value.
  • Is there a way to make information stored in a variable fade after x seconds, so it'll be technically empty? For example, direction == matches[2]
    if dirTimer then
    killTimer(tostring(dirTimer))
    end
    dirTimer = tempTimer(3, [[direction = nil]]) direction = matches[2]<br>

    change the '3' to whatever number you wanna use.



  • edited August 2017
    How do I get this:

    _G['eat_'..cure]()

    to do this (where x.y. is a namespace and subname - the "cure" part works fine, but not the namespace in the beginning)

    _G['x.y.eat_'..x.y.cure]()


    I've tried it all kinds of ways like
     _G[x.y.]['eat_'..x.y.cure]()   
    _G[x.y]['.eat_'..x.y.cure]()

    Basically I have all my "eat_<herbname>" functions and the way I have it now, it works fine..  but I'm trying to play around with the namespace stuff and it doesn't quite work.  It keeps saying something like "field is ?"  or "concatenating x.y."

  • Are x and y actual namespaces or variable that contain namespace names? If the former, x.y["eat_"..x.y.cure] if the latter it's _G[x][y]["eat_".._G[x][y].cure].
  • edited August 2017
    Keneanung said:
    Are x and y actual namespaces or variable that contain namespace names? If the former, x.y["eat_"..x.y.cure] if the latter it's _G[x][y]["eat_".._G[x][y].cure].
    The actual names.  Figured they weren't important so threw in some placeholders.

    Still doesn't like it.  would it be _G[x.y[".eat cure"..x.y.cure]] ?

    Switched it to x.y._G["eat_"..x.y.cure]  and it's saying I need an "="?

  • KlendathuKlendathu Eye of the Storm
    Is _G a function to which you're trying to pass a variable?
    _G(x.y["eat_"..cure])
    Without knowing what _G and x.y.eat_cure actually are, it's pretty hard to resolve :)

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • Maybe it would be easier if you gave your real table names and how they are structured. Then we don't need to guess around.

    _G is the global table, the one every variable and function lands in if you normally don't need to prefix it with anything. So _G.echo("something") is the same as echo("something"). You normally only need to access it if you dynamically piece something global together like in your old code.
  • _G is the reference for Lua's global scope. There is generally no need to explicitly reference it, though.
  • Assuming (based on your comments) that x is the name of a namespace (within the global scope), y is a namespace within the x namespace (a sub-namespace), and cure is the name of a variable within the scope of your code (that contains a string), then it should probably just be:

    x.y["eat_" .. cure]()

    As a more general point, the fact that you appear to have a function per herb suggests that the design of your code is... not good. You're going to end up duplicating code and making maintaining the entire thing more difficult than it needs to be.

  • Antonius said:

    Assuming (based on your comments) that x is the name of a namespace (within the global scope), y is a namespace within the x namespace (a sub-namespace), and cure is the name of a variable within the scope of your code (that contains a string), then it should probably just be:

    x.y["eat_" .. cure]()

    As a more general point, the fact that you appear to have a function per herb suggests that the design of your code is... not good. You're going to end up duplicating code and making maintaining the entire thing more difficult than it needs to be.

    Meh.. That worked. I had already tried it.  But I had the x.y.[  the stupid dot was messing it up.  I knew it was something dumb.

    Anyway, I am in the process of speeding up and making efficiencies which is why I was doing this.  Get it working the way I had in my other script first, then fix so I have a "safe state" saved.  As it turns out, I didn't need this chunk of code, but was just curious how to get it working. Though in this instance, it also didn't make it more difficult to maintain - but it did duplicate some code.  I was able to remove about 500 lines of code  in 10 or 12 functions and condense it down to 2 functions and under 50 lines of code (with one of those functions being sileris so I will modify it shortly, just wasn't top of my list right now)

    Thanks.

  • https://ada-young.appspot.com/pastebin/NV2WTeIg

    How do I capture:
    1. That there are Icewalls
    2. The directions that the icewalls are at.

    I don't know how to write the regex for it.
  • edited August 2017
    try

    An icewall is here, blocking passage to the (.+?)\.

    hmm, didn't really work, might have to pipe some triggers. I'll let other people chime in.
    "All we have to decide is what to do with the time that is given to us."

  • heh that's what I had. only matches on the first one
  • edited August 2017
    Messy;

    ^.*An icewall is here, .*$

    local t = matches[1]:split("An icewall")

    asdasdAn icewall is here, blocking passage to the down. An icewall is here, blocking passage to the 
    south.

    {
      "asdasd",
      " is here, blocking passage to the down. ",
      " is here, blocking passage to the south."
    }

    >> could then parse the split

    caveat: I hate dependent triggers
    "All we have to decide is what to do with the time that is given to us."

  • edited August 2017
    If I make a table, and later want to change a value in it, is there a way to maintain permanence or would it need to be done on login each time?

    I guess a good example would be how SVO lets you do the defense upkeep with an alias. (I don't use SVO so not sure if it has to be continuously done on login)

    Or does SVO write it out to a file and import it each time?

  • @Caelan You probably want table.save and table.load. Though I think newer versions of Mudlet make it a lot easier to persist variables without having to write code to do it.
  • Antonius said:
    @Caelan You probably want table.save and table.load. Though I think newer versions of Mudlet make it a lot easier to persist variables without having to write code to do it.
    Well, that's a duh.  Forgot Mudlet used that.

  • Can you do http requests (post/get) from mudlet?
  • Get requests work by using downloadFile(). Post not out of the box, but can be done after installing luasocket (see http://w3.impa.br/~diego/software/luasocket/ for instructioms)
  • Thank you @Keneanung,

    I'm famliar with lua socket, do I need to do anything in mudlet to load the library?
  • The usual require should work, if it's installed somewhere lua can find it.
  • Trying to find an easy way to use my Magi abilities without a hundred different aliases. 

    I've like to set a variable for the attack type (Earth, Air, etc) and be able to cycle through those when hitting an F key. 

    That way I could have:

    <p>function Smashrl()</p>
    <p>       </p>
    <p>       send("setalias sse stand/staffstrike " ..target.. " with " ..elementaltype.. " right leg/golem smash " ..target.." arms")</p>
    <p>       send("clearqueue eqbal")</p>
    <p>       send("queue add eqbal sse")</p>
    <p>end</p><p></p>


    and then when I want to change to use, say Water instead of Earth, I can hit F10 and it cycles through the options (Clearly echoing to screen) and fills the variable. 

    Any idea where to start with that, and is that even an efficient way or doing things?

Sign In or Register to comment.