I'm currently making a system for a MUD, and find myself using timers a lot to track what actions I sent to the server, so as to avoid illusions, or when to retry a cure.
eg. If I did "eat pennyroyal", I would make a timer called "sent_eat_pennyroyal" and set it to say, 1.5 seconds and then clear it as soon as I see the "You eat a pennyroyal." message.
Now, 1.5 seconds is a nice little safe buffer, but sometimes there's lag spikes and my timers go off before their time, causing me to eat several times in a row.
The GMCP of this MUD allows me to send a message 'Core.Ping' and it will send back 'Core.Ping'. By using os.clock() at when I sent mine, and then using it again and subtracting the difference when the server sends it back, I end up getting a rough estimation for my ping times.
Unfortunately, I'm not very good at designing these things. I want to make my timers more dynamic based on your latency instead of a flat 1.5 seconds.
My problem is, how often should I send core.ping to get an average ping time? And when I do, how should I use this information to modify my timers? (eg. If I get a constant ping of 200, how many seconds should I put as minimum?)
How would you guys do it?
eg. If I did "eat pennyroyal", I would make a timer called "sent_eat_pennyroyal" and set it to say, 1.5 seconds and then clear it as soon as I see the "You eat a pennyroyal." message.
Now, 1.5 seconds is a nice little safe buffer, but sometimes there's lag spikes and my timers go off before their time, causing me to eat several times in a row.
The GMCP of this MUD allows me to send a message 'Core.Ping' and it will send back 'Core.Ping'. By using os.clock() at when I sent mine, and then using it again and subtracting the difference when the server sends it back, I end up getting a rough estimation for my ping times.
Unfortunately, I'm not very good at designing these things. I want to make my timers more dynamic based on your latency instead of a flat 1.5 seconds.
My problem is, how often should I send core.ping to get an average ping time? And when I do, how should I use this information to modify my timers? (eg. If I get a constant ping of 200, how many seconds should I put as minimum?)
How would you guys do it?