1 /** 2 * Copyright (c) 2006-2012 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_WeldJoint.h" 22 23 namespace love 24 { 25 namespace physics 26 { 27 namespace box2d 28 { luax_checkweldjoint(lua_State * L,int idx)29 WeldJoint * luax_checkweldjoint(lua_State * L, int idx) 30 { 31 WeldJoint * j = luax_checktype<WeldJoint>(L, idx, "WeldJoint", PHYSICS_WELD_JOINT_T); 32 if (!j->isValid()) 33 luaL_error(L, "Attempt to use destroyed joint."); 34 return j; 35 } 36 w_WeldJoint_setFrequency(lua_State * L)37 int w_WeldJoint_setFrequency(lua_State * L) 38 { 39 WeldJoint * t = luax_checkweldjoint(L, 1); 40 float arg1 = (float)luaL_checknumber(L, 2); 41 t->setFrequency(arg1); 42 return 0; 43 } 44 w_WeldJoint_getFrequency(lua_State * L)45 int w_WeldJoint_getFrequency(lua_State * L) 46 { 47 WeldJoint * t = luax_checkweldjoint(L, 1); 48 lua_pushnumber(L, t->getFrequency()); 49 return 1; 50 } 51 w_WeldJoint_setDampingRatio(lua_State * L)52 int w_WeldJoint_setDampingRatio(lua_State * L) 53 { 54 WeldJoint * t = luax_checkweldjoint(L, 1); 55 float arg1 = (float)luaL_checknumber(L, 2); 56 t->setDampingRatio(arg1); 57 return 0; 58 } 59 w_WeldJoint_getDampingRatio(lua_State * L)60 int w_WeldJoint_getDampingRatio(lua_State * L) 61 { 62 WeldJoint * t = luax_checkweldjoint(L, 1); 63 lua_pushnumber(L, t->getDampingRatio()); 64 return 1; 65 } 66 67 static const luaL_Reg functions[] = { 68 { "setFrequency", w_WeldJoint_setFrequency }, 69 { "getFrequency", w_WeldJoint_getFrequency }, 70 { "setDampingRatio", w_WeldJoint_setDampingRatio }, 71 { "getDampingRatio", w_WeldJoint_getDampingRatio }, 72 // From Joint. 73 { "getType", w_Joint_getType }, 74 { "getAnchors", w_Joint_getAnchors }, 75 { "getReactionForce", w_Joint_getReactionForce }, 76 { "getReactionTorque", w_Joint_getReactionTorque }, 77 { "getCollideConnected", w_Joint_getCollideConnected }, 78 { "destroy", w_Joint_destroy }, 79 { 0, 0 } 80 }; 81 luaopen_weldjoint(lua_State * L)82 extern "C" int luaopen_weldjoint(lua_State * L) 83 { 84 return luax_register_type(L, "WeldJoint", functions); 85 } 86 87 } // box2d 88 } // physics 89 } // love 90