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

Quick Coding Questions

16781012

Comments

  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    @Israyhl Open your scripts window: Class svo -> svo -> svo Utilities -> Custom prompt tags -> @affs

    Use that as an example.
    Huh. Neat.
  • IsrayhlIsrayhl Member Posts: 121 ✭✭✭ - Distinguished
    Well then. That worked oddly easily. Thank you @Ahmet!
  • KlendathuKlendathu Eye of the StormMember Posts: 2,334 @@ - Legendary Achaean
    Israyhl said:
    So I am attempting to convert the prompt list of svo affs (from the @affs tag) into a table or something that I can instead echo into a miniConsole within my gui instead of in my prompt.

    I can get things working via cecho to display in the MiniConsole, but I can't populate a table/variable with the relevant data needed to have it echo in the miniConsole.

    Help?
    They're already in a table, they have to be for the prompt tag to echo them. Can't remember precisely what the table's called, something like svo.affl

    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."

  • OmorOmor Member Posts: 756 ✭✭✭✭ - Eminent
    I am attempting to make a target affliction tracker, because AK works terribly with a lot of my premade scripts. Anyone have any tips to make this easier? If the answer's too long, feel free to shoot me a message on here.
    Omor Ceberek - Targossas

    got gud
    Bade
  • IsrayhlIsrayhl Member Posts: 121 ✭✭✭ - Distinguished
    Klendathu said:
    Israyhl said:
    So I am attempting to convert the prompt list of svo affs (from the @affs tag) into a table or something that I can instead echo into a miniConsole within my gui instead of in my prompt.

    I can get things working via cecho to display in the MiniConsole, but I can't populate a table/variable with the relevant data needed to have it echo in the miniConsole.

    Help?
    They're already in a table, they have to be for the prompt tag to echo them. Can't remember precisely what the table's called, something like svo.affl
    So far, I've been lazy and just copied the function that makes the table that echoes to the prompt table, and changed the return portion to a cecho to the miniconsole. Has been working beautifully so far, although I'm trying to work out how to take out the [] that shows up in the console from bleeding. Also works for limb/aff tracking prompt tags in the same manner. I'll keep people updated if I totally break something by doing it that way. :P
  • CamrothCamroth Member Posts: 78 ✭✭✭ - Distinguished
    edited March 4
    I'm trying to figure out how to remove a variable key from a table.

    For example if I had the trigger --^(\w+) had a little lamb\.$

    I could use: --table.insert(protaganist.names, matches[2]) to add the name to the table.

    But I am having trouble removing the name from the table. If I had a similar trigger.
    --Everywhere that (\w+) went\.$
    --table.remove(protaganist.names, matches[2]) does nothing.

    I could remove it by table.remove(protaganist.names, 1) but that doesn't help me if I had a long list of names from an enemy list, as I would not be able to determine whose name was in what position in the table.

    If I use protaganist.names= nil then it kills the whole table.

    How can I do this properly?

  • TorinnTorinn Member Posts: 234 ✭✭✭ - Distinguished
    You want to set the table entry, at index key, to nil

    table[protagonist.names]=nil
  • KeneanungKeneanung Member Posts: 517 ✭✭✭✭ - Eminent
    You'll need to find the index of the value you want to remove. There is http://wiki.mudlet.org/w/Manual:Lua_Functions#table.index_of for that. So you'd need to table.remove(protagonist.names, table.index_of(matches[2]))
    CamrothCaelan
  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    edited March 4
    table.remove(protaganist.names, table.index_of(protaganist.names, matches[2]))

    table.remove takes two arguments, a table and a number, not a table and a value.

    Also, it's P R O T A G O N I S T oh my god.

    <3 @Camroth

    EDIT: Double-ninja'd.

    Also, don't do what Torinn said. That just doesn't do nothin.
    Huh. Neat.
    Camroth
  • CamrothCamroth Member Posts: 78 ✭✭✭ - Distinguished
    Ahmet said:


    Also, it's P R O T A G O N I S T oh my god.


    I'll have you know I even googled protagonist before I went back to the forums tab and still misspelled that shit.  smh
  • TorinnTorinn Member Posts: 234 ✭✭✭ - Distinguished
    edited March 4
    Yeah it works if you are inserting the protagonist as the key in the table.  It's what I use to display target and personal afflictions, and remove them when cured. Though granted the index of function is not something I knew existed
  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    The figure of Soandso blurs, and you notice a puzzled expression forming on his face before he vanishes from sight.

    This is... what now?
    Huh. Neat.
  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    Ahmet said:
    The figure of Soandso blurs, and you notice a puzzled expression forming on his face before he vanishes from sight.

    This is... what now?
    Whoops, wrong thread.
    Huh. Neat.
  • TahquilTahquil Member Posts: 3,551 @@ - Legendary Achaean
    Really simple question:

    I have a function in a script I want to call on Variables 'mayaHit' and 'mayaMiss'. I added these two variables to the variables tab but each time I start mudlet they are gone. How do I make them stay?
  • AtalkezAtalkez Member Posts: 3,662 @@ - Legendary Achaean
    Add it to the trigger you have for login events. Most people use the password correct line.


    You hug Aurora compassionately.
  • RyzethRyzeth Member Posts: 1,049 ✭✭✭✭✭ - Grand Achaean
    edited April 10
    Tahquil said:
    You can add:
      mayaHit = mayaHit or 0
      mayaMiss = mayaMiss or 0
    at the start of the function. Change 0 to whatever you want it to initialise as. That'll keep their value as whatever they are, when you do the function, or set it to 0 if the variable isn't initialised. Eg.
      function functionName()
         mayaHit = mayaHit or 0
         mayaMiss = mayaMiss or 0
         <actual function stuff>

      end
    DochithaUtianima
  • AccipiterAccipiter Member Posts: 231 ✭✭✭ - Distinguished
    Tahquil said:
    Really simple question:

    I have a function in a script I want to call on Variables 'mayaHit' and 'mayaMiss'. I added these two variables to the variables tab but each time I start mudlet they are gone. How do I make them stay?
    If you are adding it to a crit counter or something you need to save the variables outside of Mudlet, the rest of what you are using should do that somewhere so you want to add to that.
  • SobriquetSobriquet Member Posts: 1,363 @@ - Legendary Achaean
    Ryzeth said:
    Tahquil said:
    You can add:
      mayaHit = mayaHit or 0
      mayaMiss = mayaMiss or 0
    at the start of the function. Change 0 to whatever you want it to initialise as. That'll keep their value as whatever they are, when you do the function, or set it to 0 if the variable isn't initialised. Eg.
      function functionName()
         mayaHit = mayaHit or 0
         mayaMiss = mayaMiss or 0
         <actual function stuff>

      end
    This might come in useful. I have a variable for my 2H Focus which I need to set manually everytime I log in...
    image
  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    Just declare them in a script. Scripts are run at load.
    Huh. Neat.
  • SobriquetSobriquet Member Posts: 1,363 @@ - Legendary Achaean
    I have a problem where the variables don't initialize until I go into the script editor, I don't have to change anything, just the process of deselecting and selecting it again does the trick

    For example
    function wsys.prompttags.sobfocus()
    if focus == "speed" then
    return "SPD"
    else
    return "PRC"
    end
    end
    I then have this triggered on login:

    focus = "speed"

    but I get this until I go into the scripts.

    5847h 4921m 100%e100%w @sobfocus|XX|EEC M 20:59:48.969|

    It's the same for my weapon variable, and oddly my hunting alias.

    ALSO, once that is configured, I then Dragonform and lose my prompt completely...

    Any ideas?
    image
  • AntoniusAntonius Member Posts: 3,934 @@ - Legendary Achaean
    Your script is presumably before the wundersys scripts, so the wsys namespace doesn't exist yet and your script throws an error. There's an event for wundersys loading, so you would need to bind an event handler to that to set up your prompt tags. I could be more help if I wasn't on mobile.
    Sobriquet
  • KalilaKalila Member Posts: 86 ✭✭✭ - Distinguished
    Hi.

    Is there a way I can make
    getTimestamp(getLineCount())
    Only show seconds/miliseconds? Or is there another function I can make do this?
  • SobriquetSobriquet Member Posts: 1,363 @@ - Legendary Achaean
    I've used deleteLine() to remove some of the spam during a fight, but it still gives me the prompt, meaning if gag four lines I get:

    5397h 4921m 99%e96%w SWD PRC||EEM 12:46:26.682|0 0-0 0 0-0
    5397h 4921m 99%e96%w SWD PRC||EEM 12:46:26.833|0 0-0 0 0-0
    5397h 4921m 99%e96%w SWD PRC||EEM 12:46:26.848|0 0-0 0 0-0
    5397h 4921m 99%e96%w SWD PRC||EEM 12:46:26.861|0 0-0 0 0-0

    Anyway around that with gagging?
    image
  • RyzethRyzeth Member Posts: 1,049 ✭✭✭✭✭ - Grand Achaean
    edited April 12
    deleteLine() doesn't delete the prompt.

    Are you using svo or wundersys? If svo and you have a custom prompt,  use svo.deleteLineP() -- If no custom prompt, or you're using wundersys, use deleteFull()
    Sobriquet
  • AntoniusAntonius Member Posts: 3,934 @@ - Legendary Achaean
    @Kalila: Presumably it returns a string, so you can use something like this to grab the ss.zzz part at the end:

    local s = getTimestamp(getLineCount())
    local myTime = s:sub(#s - 5)

    @Sobriquet: Use deleteFull() instead, which will delete the current line and the line immediately following it if it's a prompt.
    Sobriquet
  • KalilaKalila Member Posts: 86 ✭✭✭ - Distinguished
    Antonius said:
    @Kalila: Presumably it returns a string, so you can use something like this to grab the ss.zzz part at the end:

    local s = getTimestamp(getLineCount())
    local myTime = s:sub(#s - 5)

    @Sobriquet: Use deleteFull() instead, which will delete the current line and the line immediately following it if it's a prompt.
    This was super helpful, made something work, thanks a lot @Antonius.
  • KryptonKrypton shi-KhurenaMember Posts: 1,841 @@ - Legendary Achaean
    For regex

    How do you write your trigger off these two lines:
    [FW message] abc de f6 (A message)
    [FW message] AB CDEF6 (B message)

    So that "abc de f6" and "AB CDEF6" are captured, and the reflex command "msg krypton @1"
    gives you:
    msg krypton abc de f6
    msg krypton AB CDEF6
    (Mhaldor): Herenicus says, "Apologies, I am in-and-out of hold with Verizon wireless customer service."
  • AhmetAhmet Wherever I wanna beMember Posts: 3,058 @@ - Legendary Achaean
    ^\[FW message\] ([aA][bB] ?[cC][dD] ?[eE][fF]6)$

    Maybe? If I understand what you're asking?
    Huh. Neat.
  • KryptonKrypton shi-KhurenaMember Posts: 1,841 @@ - Legendary Achaean
    edited April 13
    Match a wildcard string. "abc de f6" and "AB CDEF6" are just examples.

    String ends before first parenthesis:
    (A
    (B
    (anything
    (Mhaldor): Herenicus says, "Apologies, I am in-and-out of hold with Verizon wireless customer service."
  • DurianDurian Member Posts: 105 ✭✭✭ - Distinguished
    I would presume the following:

    ^\[FW message\] (.+) \(A message\)$
    ^\[FW message\] (.+) \(B message\)$

    That would capture the two you're talking about.
    Krypton
Sign In to Comment.