Page 1 of 1

Why can't events take large numbers?

Posted: Mon Feb 03, 2014 4:36 pm
by Jor'Mox
When I use raiseEvent, and try to pass a numerical argument (or a string that can be represented as a number), any number over 999999 is instead passed as 0. Why is there such an arbitrary upper limit?

Re: Why can't events take large numbers?

Posted: Mon Feb 03, 2014 5:09 pm
by Akaya
Tried this out myself. Same result. Very odd.

Re: Why can't events take large numbers?

Posted: Thu Feb 06, 2014 7:22 am
by Vadi
There is no limit on this that I remember, but it's not something I've ran into - I'll check this out when I can.

Re: Why can't events take large numbers?

Posted: Thu Feb 06, 2014 3:46 pm
by Jor'Mox
I ran into the issue while trying to pass experience totals via an event. It was working fine until people were reaching higher levels, where it would suddenly stop working. So I made a simple function that would display an argument passed to it via an event. Then I just gave it bigger and bigger numbers until it stopped working. Initially I did powers of two (thinking there might be some variable size limiting issue). Once I was over 1,000,000 I was seeing 0 instead, and boundary testing revealed it wasn't the closest power of two where the problem showed up, but at exactly 1,000,000. To be sure other possibly related functions weren't to blame, I successfully used numbers over 1,000,000 with tonumber, pcall, and the variable argument syntax (...), and display. I also tested with numbers without a bunch of zeros in case it was truncating, rather than just setting to zero. 1,111,111 also gets passed as zero, so it has to be just getting set to zero.

Re: Why can't events take large numbers?

Posted: Fri Feb 07, 2014 9:58 pm
by Vadi
The issue comes from the code doing a toInt() in one place on Lua numbers which are double by default. Internally, a numbe like 1000000 gets converted into 1e+06 on which toInt() gives 0. toDouble() gives the proper result, so it is an easy fix. I'm not sure why is the original code doing this.

Re: Why can't events take large numbers?

Posted: Fri Feb 07, 2014 10:05 pm
by Jor'Mox
Oh, wow, I didn't even notice that it also set numbers with decimal parts to 0 (but I double checked, and it does). Thanks for checking this out Vadi. :-)

Re: Why can't events take large numbers?

Posted: Sat Feb 08, 2014 2:36 am
by Vadi
Yeah. This'll be fixed next release: https://github.com/Mudlet/Mudlet/commit ... c64163a8a7.

Re: Why can't events take large numbers?

Posted: Sat Oct 04, 2014 10:11 pm
by Vadi
This is fixed in the upcoming 3.0 release, you can grab the preview of it at http://www.mudlet.org/download.