lua-users home
lua-l archive

Did they mean "." or ":"?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm working on a C++ game that uses Lua scripts to control robot players. I'm noticing a common error that the scripters are making, and am looking for a way to detect it and print a helpful error message.
When the scripters should be writing:
bot:setAngle(angle)
they often write:
bot.setAngle(angle)
which looks similar but is of course very different. However, anyone with much experience in Java, C++, etc., is conditioned to see the second (wrong) version as right, so this is a very difficult bug to detect while reading the code. In the setAngle function, I check that the correct number of parameters is passed, and I generate an error message if that happens. What I'd like to do is augment that mechanism by checking if the user used the "." variant and display a different message that suggests they verify that they meant to use "." and not ":". Is there a way from C++ to figure out if a function was called using "." as opposed to ":"?
Thanks!

AltStyle によって変換されたページ (->オリジナル) /