Quick Coding Questions

1356724

Comments

  • Lyr said:
    One question would be: how does the HTML5 client know what time it is?

    You mean what ingame time it is or your time?

  • Dairon said:
    I'm on a Mac and Mudlet always starts up too small for anything. 

    Is there a way to set the main window size to a certain size so I don't have to resize each time I log into Achaea?
    As far as I know, there is no setting for that.
  • TharvisTharvis The Land of Beer and Chocolate!
    Keneanung said:

    Dairon said:
    I'm on a Mac and Mudlet always starts up too small for anything. 

    Is there a way to set the main window size to a certain size so I don't have to resize each time I log into Achaea?
    As far as I know, there is no setting for that.
    I use mudlet on my mac and it never automatically resets my mudlet window size, may be an error?
    Aurora says, "Tharvis, why are you always breaking things?!"
    Artemis says, "You are so high maintenance, Tharvis, gosh."
    Tecton says, "It's still your fault, Tharvis."

  • I remember a bug with version 3 that should be fixed now... But I am not sure if part of the fix was setting the size at startup to a fixed value...
  • Tharvis said:
    Keneanung said:

    Dairon said:
    I'm on a Mac and Mudlet always starts up too small for anything. 

    Is there a way to set the main window size to a certain size so I don't have to resize each time I log into Achaea?
    As far as I know, there is no setting for that.
    I use mudlet on my mac and it never automatically resets my mudlet window size, may be an error?
    If that's the case, should I reinstall mudlet? 
    The problem during start up is fine, really. What really gets me ticked is when I type something really long (in the command line) and the window automatically shrinks back to the minuscule little size it starts off in. This makes customizing ANYTHING pretty challenging. 

    Is it at all possible to script the main window size to a certain width, pixel wise? I resize my containers this way, and there's ways to make the border sizes vary.. but is it possible with the main window?

  • TharvisTharvis The Land of Beer and Chocolate!
    Dairon said:
    Tharvis said:
    Keneanung said:

    Dairon said:
    I'm on a Mac and Mudlet always starts up too small for anything. 

    Is there a way to set the main window size to a certain size so I don't have to resize each time I log into Achaea?
    As far as I know, there is no setting for that.
    I use mudlet on my mac and it never automatically resets my mudlet window size, may be an error?
    If that's the case, should I reinstall mudlet? 
    The problem during start up is fine, really. What really gets me ticked is when I type something really long (in the command line) and the window automatically shrinks back to the minuscule little size it starts off in. This makes customizing ANYTHING pretty challenging. 

    Is it at all possible to script the main window size to a certain width, pixel wise? I resize my containers this way, and there's ways to make the border sizes vary.. but is it possible with the main window?


    only thing I can find about the command line is "minimum height in pixels" setting, and as far as I know it's not possible to script size the main window

    I do vaguely recall having your problem a few years ago, can't remember the specifics of how I fixed it - back up your profile and reinstall mudlet?
    (also, are you using mudlet 2.1 or mudlet 3?)
    Aurora says, "Tharvis, why are you always breaking things?!"
    Artemis says, "You are so high maintenance, Tharvis, gosh."
    Tecton says, "It's still your fault, Tharvis."

  • That is definitely mudlet 3. If you have the delta version, then there was no official build since fixing the bug, but it is in...
  • Yes, I'm using mudlet 3. So I need to reinstall back to mudlet 2.1? 
  • If you are on delta and don't want that bug.. Yeah...
  • AustereAustere Tennessee
    Is there a newer release out than delta? Not seen any mudlet news in months. 
  • No release, but you can compile the source tree yourself if you want.
    retired
  • AustereAustere Tennessee
    Seifur said:
    No release, but you can compile the source tree yourself if you want.
    I feel like when it comes to this stuff, if anyone is capable of breaking something it's me, which is the main reason I chose to not beg Vadi for permission to work on Svo. I think leaving these types of things to people that actually know how to code is probably in my best interests..Can't wait for more wonderful releases from team mudlet, though!
  • Is there a way to set a trigger so that it only fires if it occurs directly after I've input some command?  I have a trigger for reave which disables svo and serverside when I start the instakill: I'd like something that turns them back on if the reave fails because I do something - but don't want to trigger it solely from the failure line, because that's illusion fodder!
  • @Adet You can use enableTrigger("Trigger name") and disableTrigger("Trigger name") to enable/disable the trigger. So you'd enable it in your alias for Reave, then you'd disable it on both the failure and completion lines.
  • Thanks - but that would presumably still allow someone to illusion it during the Reave, turning my curing back on?
  • Ah, so you want it to be enabled on entering any command other than Reave? Could do it with an event handler for a command being sent, and compare it to the syntax for Reave; enable if it doesn't match, otherwise disable it. The only potential problem would be commands that don't actually get completely sent due to Svo's aeon block, for example.
  • Adet said:
    Is there a way to set a trigger so that it only fires if it occurs directly after I've input some command?  I have a trigger for reave which disables svo and serverside when I start the instakill: I'd like something that turns them back on if the reave fails because I do something - but don't want to trigger it solely from the failure line, because that's illusion fodder!
    While it's not a coding answer, I have big highlights for various things with my instakills and manually unpause as I prefer the manual control over it. Couldn't you set a variable for when you enter the command and only fire on the trigger line if the variable is set? Although, I guess that still leaves you open to the illusion

    (Party): Mezghar says, "Stop."
  • edited October 2015
    I've got three questions, not sure if they are quick. 
    1. I'm seeing a random number of small blue (cyan) periods (dots) next to my prompt. I'm using AK, Wundersys, and so far I've only been able to figure out that it isn't a part of owsysprompt(). 

    2. My wsys.doradd("butcher corpse") ends up queuing "touch shield" instead, probably from the alias "ts" which sends -- wsys.dofirst("touch shield"). Not sure why it's doing that.. I've tried clearing the dor queue but it still won't clear it. 

    3. My DOR has been getting slower and slower, recently with the last update. I've figured it might be due to wsys.myPing() being super high (I've made a quick fix of making it 0.1, which is a LITTLE bit better). the function in the script says wsys.myPing()*3, which makes anything and everything super slow and unusable. 

    Thanks again for the help! I've been wracking my head and I just haven't been able to find the help in game. 

    edit: also, problem 1 seems to have occured near around the time I tried to import Keneanung's bashing script. 
  • I'm 99% sure 1 is AK.

    2 sounds like it's the same thing other people have been mentioning on the forums. Try setting the QUEUESHOWALERTS (or whatever it's actually called) config option to YES/TRUE/ON again in-game.

    No idea about 3 though, sorry.
  • @Antonius Thanks, #2 was fixed. 
    #1 is still messing with me, but thankfully it doesn't have any downsides other than visual effects. 
    #3 is also not as urgent, as I only use DOR for butchering. Also, I managed to get to 157 queued commands using #wsys.doqueue.. so I decided to not use the doqueue until I know how it works
  • AustereAustere Tennessee
    The blue dot is Ak. There is also a yellow one.  It's part of a prompt trigger, so I know if it hangs up/errors and never closes.  You should only see it once after every attack
  • Austere said:
    The blue dot is Ak. There is also a yellow one.  It's part of a prompt trigger, so I know if it hangs up/errors and never closes.  You should only see it once after every attack
    What happens when I see like 8 of them? It varies between 1 and 8~9ish, more likely to be  >1 than 1. Should I do something to get rid of it?
  • AustereAustere Tennessee
    Dairon said:
    Austere said:
    The blue dot is Ak. There is also a yellow one.  It's part of a prompt trigger, so I know if it hangs up/errors and never closes.  You should only see it once after every attack
    What happens when I see like 8 of them? It varies between 1 and 8~9ish, more likely to be  >1 than 1. Should I do something to get rid of it?
    Then you have an error.  Should drop me a log of it and a copy of your errors view, and I can see about fixing you up.  
  • Austere said:
    Dairon said:
    Austere said:
    The blue dot is Ak. There is also a yellow one.  It's part of a prompt trigger, so I know if it hangs up/errors and never closes.  You should only see it once after every attack
    What happens when I see like 8 of them? It varies between 1 and 8~9ish, more likely to be  >1 than 1. Should I do something to get rid of it?
    Then you have an error.  Should drop me a log of it and a copy of your errors view, and I can see about fixing you up.  
    Ok will do! me doing "orl" (or any other dragon default alias) completely shuts down mudlet, so maybe this might be related. I'll send you a message. Thanks much! 
  • AustereAustere Tennessee
    edited October 2015
    Dairon said:
    Austere said:
    Dairon said:
    Austere said:
    The blue dot is Ak. There is also a yellow one.  It's part of a prompt trigger, so I know if it hangs up/errors and never closes.  You should only see it once after every attack
    What happens when I see like 8 of them? It varies between 1 and 8~9ish, more likely to be  >1 than 1. Should I do something to get rid of it?
    Then you have an error.  Should drop me a log of it and a copy of your errors view, and I can see about fixing you up.  
    Ok will do! me doing "orl" (or any other dragon default alias) completely shuts down mudlet, so maybe this might be related. I'll send you a message. Thanks much! 
    Sounds to me like you have a function looping somewhere(probably one of the prompt triggers).  The dragon stuff shouldn't be working in 4.1 anyway, since the gmcp output for race was changed some in dragon. Easy fix, and once I plan to address, so I don't have to walk everyone through it.  

    I have improved my prompt triggers beyond belief, so I might go ahead and update that too. Will definitely look into it, though.  It can be a pain to take newer logic and revert back into older scripts, so you might get stuck fixing that one on your own.  Logs with errors would definitely reveal more. 

    Edit: can message ig, pm forums, or post here
  • For sniping I currently trigger the "Your aim is true" line to then fire the snipe, but finds this conflicts with pinshot. Anyone got a quick neat sniping script I can learn from?

    (Party): Mezghar says, "Stop."
  • Managed to fix all three problems, thanks to @Antonius and @Austere . Thanks guys.
    Also had a problem where my wsys.doqueue and wsys.dofreequeue gets cluttered. I know @Monev had the problem too. I do a quick fix of just making them both =nil.. but is there a way I can do a complete fix?
  • Could someone explain the significance of the letters in: "for i,v in pairs" Or when k,v is mentioned?

    (Party): Mezghar says, "Stop."
  • 7.3 – Stateless Iterators

    As the name implies, a stateless iterator is an iterator that does not keep any state by itself. Therefore, we may use the same stateless iterator in multiple loops, avoiding the cost of creating new closures.

    On each iteration, the for loop calls its iterator function with two arguments: the invariant state and the control variable. A stateless iterator generates the next element for the iteration using only these two arguments. A typical example of this kind of iterator is ipairs, which iterates over all elements in an array, as illustrated next:

        a = {"one", "two", "three"}
        for i, v in ipairs(a) do
          print(i, v)
        end
    
    The state of the iteration is the table being traversed (the invariant state, which does not change during the loop), plus the current index (the control variable). Both ipairs and the iterator it returns are quite simple; we could write them in Lua as follows:
        function iter (a, i)
          i = i + 1
          local v = a[i]
          if v then
            return i, v
          end
        end
        
        function ipairs (a)
          return iter, a, 0
        end
    
    When Lua calls ipairs(a) in a for loop, it gets three values: the iter function as the iterator, a as the invariant state, and zero as the initial value for the control variable. Then, Lua calls iter(a, 0), which results in 1, a[1] (unless a[1] is already nil). In the second iteration, it calls iter(a, 1), which results in 2, a[2], and so on, until the first nil element.

    The pairs function, which iterates over all elements in a table, is similar, except that the iterator function is the next function, which is a primitive function in Lua:

        function pairs (t)
          return next, t, nil
        end
    
    The call next(t, k), where k is a key of the table t, returns a next key in the table, in an arbitrary order. (It returns also the value associated with that key, as a second return value.) The call next(t, nil) returns a first pair. When there are no more pairs, next returnsnil.

    Some people prefer to use next directly, without calling pairs:

        for k, v in next, t do
          ...
        end
    
    Remember that the expression list of the for loop is adjusted to three results, so Lua gets nextt, and nil, exactly what it gets when it callspairs(t).


  • The short version: they're variable declarations, and the actual names chosen are arbitrary (i = index [for ordered lists], k = key [for dictionaries], v = value). So, for each iteration, i/k stores the index/key, and v stores the value that index/key corresponds to.

    You can call them whatever you like though, and I find it's helpful - especially when nesting iterations - to actually give them proper names that correspond to what they are. For example, my rite tracking script has a dictionary (I'll call it 'mydict' for this) that maps room ids to another dictionary that stores the duration of each rite in that room. So when iterating over that first dictionary, rather than 'for k, v in pairs(mydict) do' my code would be 'for roomid, rites in pairs(mydict)'. If I was then, inside of that iterator, iterating over that inner dictionary (i.e. what 'rites' refers to), I'd do 'for rite, duration in pairs(rites)'.

Sign In or Register to comment.