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_MotorJoint.h"
22
23namespace love
24{
25namespace physics
26{
27namespace box2d
28{
29
30MotorJoint *luax_checkmotorjoint(lua_State *L, int idx)
31{
32 MotorJoint *j = luax_checktype<MotorJoint>(L, idx);
33 if (!j->isValid())
34 luaL_error(L, "Attempt to use destroyed joint.");
35 return j;
36}
37
38int w_MotorJoint_setLinearOffset(lua_State *L)
39{
40 MotorJoint *t = luax_checkmotorjoint(L, 1);
41 float x = (float) luaL_checknumber(L, 2);
42 float y = (float) luaL_checknumber(L, 3);
43 t->setLinearOffset(x, y);
44 return 0;
45}
46
47int w_MotorJoint_getLinearOffset(lua_State *L)
48{
49 MotorJoint *t = luax_checkmotorjoint(L, 1);
50 return t->getLinearOffset(L);
51}
52
53int w_MotorJoint_setAngularOffset(lua_State *L)
54{
55 MotorJoint *t = luax_checkmotorjoint(L, 1);
56 float arg1 = (float) luaL_checknumber(L, 2);
57 t->setAngularOffset(arg1);
58 return 0;
59}
60
61int w_MotorJoint_getAngularOffset(lua_State *L)
62{
63 MotorJoint *t = luax_checkmotorjoint(L, 1);
64 lua_pushnumber(L, t->getAngularOffset());
65 return 1;
66}
67
68int w_MotorJoint_setMaxForce(lua_State *L)
69{
70 MotorJoint *t = luax_checkmotorjoint(L, 1);
71 float arg1 = (float) luaL_checknumber(L, 2);
72 luax_catchexcept(L, [&](){ t->setMaxForce(arg1); });
73 return 0;
74}
75
76int w_MotorJoint_getMaxForce(lua_State *L)
77{
78 MotorJoint *t = luax_checkmotorjoint(L, 1);
79 lua_pushnumber(L, t->getMaxForce());
80 return 1;
81}
82
83int w_MotorJoint_setMaxTorque(lua_State *L)
84{
85 MotorJoint *t = luax_checkmotorjoint(L, 1);
86 float arg1 = (float) luaL_checknumber(L, 2);
87 luax_catchexcept(L, [&](){ t->setMaxTorque(arg1); });
88 return 0;
89}
90
91int w_MotorJoint_getMaxTorque(lua_State *L)
92{
93 MotorJoint *t = luax_checkmotorjoint(L, 1);
94 lua_pushnumber(L, t->getMaxTorque());
95 return 1;
96}
97
98int w_MotorJoint_setCorrectionFactor(lua_State *L)
99{
100 MotorJoint *t = luax_checkmotorjoint(L, 1);
101 float arg1 = (float) luaL_checknumber(L, 2);
102 luax_catchexcept(L, [&](){ t->setCorrectionFactor(arg1); });
103 return 0;
104}
105
106int w_MotorJoint_getCorrectionFactor(lua_State *L)
107{
108 MotorJoint *t = luax_checkmotorjoint(L, 1);
109 lua_pushnumber(L, t->getCorrectionFactor());
110 return 1;
111}
112
113static const luaL_Reg w_MotorJoint_functions[] =
114{
115 { "setLinearOffset", w_MotorJoint_setLinearOffset },
116 { "getLinearOffset", w_MotorJoint_getLinearOffset },
117 { "setAngularOffset", w_MotorJoint_setAngularOffset },
118 { "getAngularOffset", w_MotorJoint_getAngularOffset },
119 { "setMaxForce", w_MotorJoint_setMaxForce },
120 { "getMaxForce", w_MotorJoint_getMaxForce },
121 { "setMaxTorque", w_MotorJoint_setMaxTorque },
122 { "getMaxTorque", w_MotorJoint_getMaxTorque },
123 { "setCorrectionFactor", w_MotorJoint_setCorrectionFactor },
124 { "getCorrectionFactor", w_MotorJoint_getCorrectionFactor },
125 { 0, 0 }
126};
127
128extern "C" int luaopen_motorjoint(lua_State *L)
129{
130 return luax_register_type(L, &MotorJoint::type, w_Joint_functions, w_MotorJoint_functions, nullptr);
131}
132
133
134} // box2d
135} // phyics
136} // love
137