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_PulleyJoint.h" |
22 | |
23 | namespace love |
24 | { |
25 | namespace physics |
26 | { |
27 | namespace box2d |
28 | { |
29 | |
30 | PulleyJoint *luax_checkpulleyjoint(lua_State *L, int idx) |
31 | { |
32 | PulleyJoint *j = luax_checktype<PulleyJoint>(L, idx); |
33 | if (!j->isValid()) |
34 | luaL_error(L, "Attempt to use destroyed joint." ); |
35 | return j; |
36 | } |
37 | |
38 | int w_PulleyJoint_getGroundAnchors(lua_State *L) |
39 | { |
40 | PulleyJoint *t = luax_checkpulleyjoint(L, 1); |
41 | lua_remove(L, 1); |
42 | return t->getGroundAnchors(L); |
43 | } |
44 | |
45 | int w_PulleyJoint_getLengthA(lua_State *L) |
46 | { |
47 | PulleyJoint *t = luax_checkpulleyjoint(L, 1); |
48 | lua_pushnumber(L, t->getLengthA()); |
49 | return 1; |
50 | } |
51 | |
52 | int w_PulleyJoint_getLengthB(lua_State *L) |
53 | { |
54 | PulleyJoint *t = luax_checkpulleyjoint(L, 1); |
55 | lua_pushnumber(L, t->getLengthB()); |
56 | return 1; |
57 | } |
58 | |
59 | int w_PulleyJoint_getRatio(lua_State *L) |
60 | { |
61 | PulleyJoint *t = luax_checkpulleyjoint(L, 1); |
62 | lua_pushnumber(L, t->getRatio()); |
63 | return 1; |
64 | } |
65 | |
66 | static const luaL_Reg w_PulleyJoint_functions[] = |
67 | { |
68 | { "getGroundAnchors" , w_PulleyJoint_getGroundAnchors }, |
69 | { "getLengthA" , w_PulleyJoint_getLengthA }, |
70 | { "getLengthB" , w_PulleyJoint_getLengthB }, |
71 | { "getRatio" , w_PulleyJoint_getRatio }, |
72 | { 0, 0 } |
73 | }; |
74 | |
75 | extern "C" int luaopen_pulleyjoint(lua_State *L) |
76 | { |
77 | return luax_register_type(L, &PulleyJoint::type, w_Joint_functions, w_PulleyJoint_functions, nullptr); |
78 | } |
79 | |
80 | } // box2d |
81 | } // physics |
82 | } // love |
83 | |