| 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_DistanceJoint.h" | 
|---|
| 22 |  | 
|---|
| 23 | namespace love | 
|---|
| 24 | { | 
|---|
| 25 | namespace physics | 
|---|
| 26 | { | 
|---|
| 27 | namespace box2d | 
|---|
| 28 | { | 
|---|
| 29 |  | 
|---|
| 30 | DistanceJoint *luax_checkdistancejoint(lua_State *L, int idx) | 
|---|
| 31 | { | 
|---|
| 32 | DistanceJoint *j = luax_checktype<DistanceJoint>(L, idx); | 
|---|
| 33 | if (!j->isValid()) | 
|---|
| 34 | luaL_error(L, "Attempt to use destroyed joint."); | 
|---|
| 35 | return j; | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | int w_DistanceJoint_setLength(lua_State *L) | 
|---|
| 39 | { | 
|---|
| 40 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 41 | float arg1 = (float)luaL_checknumber(L, 2); | 
|---|
| 42 | t->setLength(arg1); | 
|---|
| 43 | return 0; | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | int w_DistanceJoint_getLength(lua_State *L) | 
|---|
| 47 | { | 
|---|
| 48 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 49 | lua_pushnumber(L, t->getLength()); | 
|---|
| 50 | return 1; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | int w_DistanceJoint_setFrequency(lua_State *L) | 
|---|
| 54 | { | 
|---|
| 55 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 56 | float arg1 = (float)luaL_checknumber(L, 2); | 
|---|
| 57 | t->setFrequency(arg1); | 
|---|
| 58 | return 0; | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | int w_DistanceJoint_getFrequency(lua_State *L) | 
|---|
| 62 | { | 
|---|
| 63 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 64 | lua_pushnumber(L, t->getFrequency()); | 
|---|
| 65 | return 1; | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | int w_DistanceJoint_setDampingRatio(lua_State *L) | 
|---|
| 69 | { | 
|---|
| 70 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 71 | float arg1 = (float)luaL_checknumber(L, 2); | 
|---|
| 72 | t->setDampingRatio(arg1); | 
|---|
| 73 | return 0; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | int w_DistanceJoint_getDampingRatio(lua_State *L) | 
|---|
| 77 | { | 
|---|
| 78 | DistanceJoint *t = luax_checkdistancejoint(L, 1); | 
|---|
| 79 | lua_pushnumber(L, t->getDampingRatio()); | 
|---|
| 80 | return 1; | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | static const luaL_Reg w_DistanceJoint_functions[] = | 
|---|
| 84 | { | 
|---|
| 85 | { "setLength", w_DistanceJoint_setLength }, | 
|---|
| 86 | { "getLength", w_DistanceJoint_getLength }, | 
|---|
| 87 | { "setFrequency", w_DistanceJoint_setFrequency }, | 
|---|
| 88 | { "getFrequency", w_DistanceJoint_getFrequency }, | 
|---|
| 89 | { "setDampingRatio", w_DistanceJoint_setDampingRatio }, | 
|---|
| 90 | { "getDampingRatio", w_DistanceJoint_getDampingRatio }, | 
|---|
| 91 | { 0, 0 } | 
|---|
| 92 | }; | 
|---|
| 93 |  | 
|---|
| 94 | extern "C"int luaopen_distancejoint(lua_State *L) | 
|---|
| 95 | { | 
|---|
| 96 | return luax_register_type(L, &DistanceJoint::type, w_Joint_functions, w_DistanceJoint_functions, nullptr); | 
|---|
| 97 | } | 
|---|
| 98 |  | 
|---|
| 99 | } // box2d | 
|---|
| 100 | } // physics | 
|---|
| 101 | } // love | 
|---|
| 102 |  | 
|---|