Quick Coding Questions

17810121324

Comments

  • AhmetAhmet Wherever I wanna be
    @Israyhl Open your scripts window: Class svo -> svo -> svo Utilities -> Custom prompt tags -> @affs

    Use that as an example.
    Huh. Neat.
  • Well then. That worked oddly easily. Thank you @Ahmet!
  • KlendathuKlendathu Eye of the Storm
    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."
  • 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
  • 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
  • edited March 2017
    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?

  • You want to set the table entry, at index key, to nil

    table[protagonist.names]=nil
    Deucalion says, "Torinn is quite nice."
  • 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]))
  • AhmetAhmet Wherever I wanna be
    edited March 2017
    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.
  • 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
  • edited March 2017
    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
    Deucalion says, "Torinn is quite nice."
  • AhmetAhmet Wherever I wanna be
    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 be
    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.
  • 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?
  • Add it to the trigger you have for login events. Most people use the password correct line.




    Penwize has cowardly forfeited the challenge to mortal combat issued by Atalkez.
  • edited April 2017
    Tahquil said:
    You can add:
    &nbsp; mayaHit = mayaHit or 0<br>&nbsp; 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.
    &nbsp; function functionName()<br>&nbsp; &nbsp; &nbsp;mayaHit = mayaHit or 0<br>&nbsp; &nbsp; &nbsp;mayaMiss = mayaMiss or 0<br>&nbsp; &nbsp; &nbsp;<actual function stuff><br><br>&nbsp; end
  • 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.
  • Ryzeth said:
    Tahquil said:
    You can add:
    &nbsp; mayaHit = mayaHit or 0<br>&nbsp; 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.
    &nbsp; function functionName()<br>&nbsp; &nbsp; &nbsp;mayaHit = mayaHit or 0<br>&nbsp; &nbsp; &nbsp;mayaMiss = mayaMiss or 0<br>&nbsp; &nbsp; &nbsp;<actual function stuff><br><br>&nbsp; end
    This might come in useful. I have a variable for my 2H Focus which I need to set manually everytime I log in...

    (Party): Mezghar says, "Stop."
  • AhmetAhmet Wherever I wanna be
    Just declare them in a script. Scripts are run at load.
    Huh. Neat.
  • 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()<br>	if focus == "speed" then<br>		return "SPD"<br>	else<br>		return "PRC"<br>	end<br>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?

    (Party): Mezghar says, "Stop."
  • 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.
  • Hi.

    Is there a way I can make
    getTimestamp(getLineCount())
    Only show seconds/miliseconds? Or is there another function I can make do this?
  • 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?

    (Party): Mezghar says, "Stop."
  • edited April 2017
    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()
  • @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.
  • 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-Khurena
    For regex

    How do you write your trigger off these two lines:
    [FW message] abc de f6 (A message)<br>[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<br>msg krypton AB CDEF6
  • AhmetAhmet Wherever I wanna be
    ^\[FW message\] ([aA][bB] ?[cC][dD] ?[eE][fF]6)$

    Maybe? If I understand what you're asking?
    Huh. Neat.
  • KryptonKrypton shi-Khurena
    edited April 2017
    Match a wildcard string. "abc de f6" and "AB CDEF6" are just examples.

    String ends before first parenthesis:
    (A<br>(B<br>(anything
  • I would presume the following:

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

    That would capture the two you're talking about.
Sign In or Register to comment.