1 | /** |
2 | * Copyright (c) 2006-2023 LOVE Development Team |
3 | * |
4 | * This software is provided 'as-is', without any express or implied |
5 | * warranty. In no event will the authors be held liable for any damages |
6 | * arising from the use of this software. |
7 | * |
8 | * Permission is granted to anyone to use this software for any purpose, |
9 | * including commercial applications, and to alter it and redistribute it |
10 | * freely, subject to the following restrictions: |
11 | * |
12 | * 1. The origin of this software must not be misrepresented; you must not |
13 | * claim that you wrote the original software. If you use this software |
14 | * in a product, an acknowledgment in the product documentation would be |
15 | * appreciated but is not required. |
16 | * 2. Altered source versions must be plainly marked as such, and must not be |
17 | * misrepresented as being the original software. |
18 | * 3. This notice may not be removed or altered from any source distribution. |
19 | **/ |
20 | |
21 | #include "wrap_WheelJoint.h" |
22 | |
23 | namespace love |
24 | { |
25 | namespace physics |
26 | { |
27 | namespace box2d |
28 | { |
29 | |
30 | WheelJoint *luax_checkwheeljoint(lua_State *L, int idx) |
31 | { |
32 | WheelJoint *j = luax_checktype<WheelJoint>(L, idx); |
33 | if (!j->isValid()) |
34 | luaL_error(L, "Attempt to use destroyed joint." ); |
35 | return j; |
36 | } |
37 | |
38 | int w_WheelJoint_getJointTranslation(lua_State *L) |
39 | { |
40 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
41 | lua_pushnumber(L, t->getJointTranslation()); |
42 | return 1; |
43 | } |
44 | |
45 | int w_WheelJoint_getJointSpeed(lua_State *L) |
46 | { |
47 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
48 | lua_pushnumber(L, t->getJointSpeed()); |
49 | return 1; |
50 | } |
51 | |
52 | int w_WheelJoint_setMotorEnabled(lua_State *L) |
53 | { |
54 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
55 | bool arg1 = luax_checkboolean(L, 2); |
56 | t->setMotorEnabled(arg1); |
57 | return 0; |
58 | } |
59 | |
60 | int w_WheelJoint_isMotorEnabled(lua_State *L) |
61 | { |
62 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
63 | luax_pushboolean(L, t->isMotorEnabled()); |
64 | return 1; |
65 | } |
66 | |
67 | int w_WheelJoint_setMotorSpeed(lua_State *L) |
68 | { |
69 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
70 | float arg1 = (float)luaL_checknumber(L, 2); |
71 | t->setMotorSpeed(arg1); |
72 | return 0; |
73 | } |
74 | |
75 | int w_WheelJoint_getMotorSpeed(lua_State *L) |
76 | { |
77 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
78 | lua_pushnumber(L, t->getMotorSpeed()); |
79 | return 1; |
80 | } |
81 | |
82 | int w_WheelJoint_setMaxMotorTorque(lua_State *L) |
83 | { |
84 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
85 | float arg1 = (float)luaL_checknumber(L, 2); |
86 | t->setMaxMotorTorque(arg1); |
87 | return 0; |
88 | } |
89 | |
90 | int w_WheelJoint_getMaxMotorTorque(lua_State *L) |
91 | { |
92 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
93 | lua_pushnumber(L, t->getMaxMotorTorque()); |
94 | return 1; |
95 | } |
96 | |
97 | int w_WheelJoint_getMotorTorque(lua_State *L) |
98 | { |
99 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
100 | float inv_dt = (float)luaL_checknumber(L, 2); |
101 | lua_pushnumber(L, t->getMotorTorque(inv_dt)); |
102 | return 1; |
103 | } |
104 | |
105 | int w_WheelJoint_setSpringFrequency(lua_State *L) |
106 | { |
107 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
108 | float arg1 = (float)luaL_checknumber(L, 2); |
109 | t->setSpringFrequency(arg1); |
110 | return 0; |
111 | } |
112 | |
113 | int w_WheelJoint_getSpringFrequency(lua_State *L) |
114 | { |
115 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
116 | lua_pushnumber(L, t->getSpringFrequency()); |
117 | return 1; |
118 | } |
119 | |
120 | int w_WheelJoint_setSpringDampingRatio(lua_State *L) |
121 | { |
122 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
123 | float arg1 = (float)luaL_checknumber(L, 2); |
124 | t->setSpringDampingRatio(arg1); |
125 | return 0; |
126 | } |
127 | |
128 | int w_WheelJoint_getSpringDampingRatio(lua_State *L) |
129 | { |
130 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
131 | lua_pushnumber(L, t->getSpringDampingRatio()); |
132 | return 1; |
133 | } |
134 | |
135 | int w_WheelJoint_getAxis(lua_State *L) |
136 | { |
137 | WheelJoint *t = luax_checkwheeljoint(L, 1); |
138 | lua_remove(L, 1); |
139 | return t->getAxis(L); |
140 | } |
141 | |
142 | static const luaL_Reg w_WheelJoint_functions[] = |
143 | { |
144 | { "getJointTranslation" , w_WheelJoint_getJointTranslation }, |
145 | { "getJointSpeed" , w_WheelJoint_getJointSpeed }, |
146 | { "setMotorEnabled" , w_WheelJoint_setMotorEnabled }, |
147 | { "isMotorEnabled" , w_WheelJoint_isMotorEnabled }, |
148 | { "setMotorSpeed" , w_WheelJoint_setMotorSpeed }, |
149 | { "getMotorSpeed" , w_WheelJoint_getMotorSpeed }, |
150 | { "setMaxMotorTorque" , w_WheelJoint_setMaxMotorTorque }, |
151 | { "getMaxMotorTorque" , w_WheelJoint_getMaxMotorTorque }, |
152 | { "getMotorTorque" , w_WheelJoint_getMotorTorque }, |
153 | { "setSpringFrequency" , w_WheelJoint_setSpringFrequency }, |
154 | { "getSpringFrequency" , w_WheelJoint_getSpringFrequency }, |
155 | { "setSpringDampingRatio" , w_WheelJoint_setSpringDampingRatio }, |
156 | { "getSpringDampingRatio" , w_WheelJoint_getSpringDampingRatio }, |
157 | { "getAxis" , w_WheelJoint_getAxis }, |
158 | { 0, 0 } |
159 | }; |
160 | |
161 | extern "C" int luaopen_wheeljoint(lua_State *L) |
162 | { |
163 | return luax_register_type(L, &WheelJoint::type, w_Joint_functions, w_WheelJoint_functions, nullptr); |
164 | } |
165 | |
166 | } // box2d |
167 | } // physics |
168 | } // love |
169 | |