| 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_FrictionJoint.h" |
| 22 | #include "wrap_Physics.h" |
| 23 | |
| 24 | namespace love |
| 25 | { |
| 26 | namespace physics |
| 27 | { |
| 28 | namespace box2d |
| 29 | { |
| 30 | |
| 31 | FrictionJoint *luax_checkfrictionjoint(lua_State *L, int idx) |
| 32 | { |
| 33 | FrictionJoint *j = luax_checktype<FrictionJoint>(L, idx); |
| 34 | if (!j->isValid()) |
| 35 | luaL_error(L, "Attempt to use destroyed joint." ); |
| 36 | return j; |
| 37 | } |
| 38 | |
| 39 | int w_FrictionJoint_setMaxForce(lua_State *L) |
| 40 | { |
| 41 | FrictionJoint *t = luax_checkfrictionjoint(L, 1); |
| 42 | float arg1 = (float)luaL_checknumber(L, 2); |
| 43 | luax_catchexcept(L, [&](){ t->setMaxForce(arg1); }); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int w_FrictionJoint_getMaxForce(lua_State *L) |
| 48 | { |
| 49 | FrictionJoint *t = luax_checkfrictionjoint(L, 1); |
| 50 | lua_pushnumber(L, t->getMaxForce()); |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | int w_FrictionJoint_setMaxTorque(lua_State *L) |
| 55 | { |
| 56 | FrictionJoint *t = luax_checkfrictionjoint(L, 1); |
| 57 | float arg1 = (float)luaL_checknumber(L, 2); |
| 58 | luax_catchexcept(L, [&](){ t->setMaxTorque(arg1); }); |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | int w_FrictionJoint_getMaxTorque(lua_State *L) |
| 63 | { |
| 64 | FrictionJoint *t = luax_checkfrictionjoint(L, 1); |
| 65 | lua_pushnumber(L, t->getMaxTorque()); |
| 66 | return 1; |
| 67 | } |
| 68 | |
| 69 | static const luaL_Reg w_FrictionJoint_functions[] = |
| 70 | { |
| 71 | { "setMaxForce" , w_FrictionJoint_setMaxForce }, |
| 72 | { "getMaxForce" , w_FrictionJoint_getMaxForce }, |
| 73 | { "setMaxTorque" , w_FrictionJoint_setMaxTorque }, |
| 74 | { "getMaxTorque" , w_FrictionJoint_getMaxTorque }, |
| 75 | { 0, 0 } |
| 76 | }; |
| 77 | |
| 78 | extern "C" int luaopen_frictionjoint(lua_State *L) |
| 79 | { |
| 80 | return luax_register_type(L, &FrictionJoint::type, w_Joint_functions, w_FrictionJoint_functions, nullptr); |
| 81 | } |
| 82 | |
| 83 | } // box2d |
| 84 | } // physics |
| 85 | } // love |
| 86 | |