-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to create a class function with more than one parameter #157
Comments
I have the same problem but with only single parameter and using float: I do the following:
// Bind the Bar class in the state and then in the .lua file:
I got the same error: [INFO]Error Script: ../data/scripts/camera_test.lua:7: bad argument #1 to 'new' (unregistered type expected, got number). I do the same example with int and double and it works correctly. If you try your example but set X and Y separatelly? Does it run ok? I use MS2015. |
I have added the define LUA_32BITS when I compile lua, and I works correct now, I have also try your case and it works fine. |
Faced this issue recently. Depending on LUA configuration (e.g. LUA_32BITS) lua_Number will be float, double or long double. The issue happens when calling a class method which accepts an argument of one of above types, but that type doesn't match lua_Number. E.g. lua_Number is float, but method is void Bar::set(double x). You should register classes with methods accepting lua_Number. You can always make a wrapper class for this purpose. |
hello everyone,
I don't know if it is a issue, a limitation or just me doing it wrong.
I made a class with a function with two parameters like this:
class MySprite {
public:
void setPosition( float x, float y );
}
and I did this to register it on lua:
state["MySprite"].SetClass<MySprite, float>("setPosition", &MySprite ::setPosition);
it compiles with no error, but, when I call this function on lua it returns this error:
/mnt/data/app/main.lua:5: bad argument # 1 to 'SetPosition' (unregistered type expected, got number),
thanks :)
The text was updated successfully, but these errors were encountered: