mherkender / lua.js

An ECMAscript framework to compile and run Lua code, allowing Lua to run in a browser or in Flash
http://blog.brokenfunction.com/
600 stars 73 forks source link

Fix Lua operator overloading #27

Closed elisee closed 11 years ago

elisee commented 11 years ago

Lua.js uses parseFloat to check whether the operand(s) are numbers or not and if they are not, looks for operator overloading.

But while it checks for null, parseFloat actually returns NaN if the parsing failed see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseFloat#Description)

This pull request fixes the checks and make operator overloading actually work.

elisee commented 11 years ago

I forgot to make a new branch rather than committing to master... I added a new commit that fixes os.time to return seconds rather than milliseconds as per http://www.lua.org/manual/5.1/manual.html#5.8

mherkender commented 11 years ago

Sorry I didn't get to this sooner. Thanks for both fixes!

elisee commented 11 years ago

No problem, thanks for an awesome library! :) I'm porting the CraftStudio runtime to the Web (http://www.youtube.com/watch?v=TjHSb_XdVKM) and it's been incredibly helpful.

mherkender commented 11 years ago

Cool! Glad to see its helping people.