From 624744ca990aecbb22cea03a6bc93cbf39b041e5 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Tue, 17 Dec 2013 18:49:03 +0100 Subject: [PATCH] Lua API: Setter/getter for gravity --- Aquaria/ScriptInterface.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 79f264f..3284ced 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -1235,6 +1235,26 @@ luaFunc(obj_isInternalVelIn) luaReturnBool(r ? r->velocity.isLength2DIn(lua_tonumber(L, 2)) : false); } +luaFunc(obj_setGravity) +{ + RenderObject *r = robj(L); + if (r) + { + r->gravity.stop(); + interpolateVec2(L, r->gravity, 2); + } + luaReturnNil(); +} + +luaFunc(obj_getGravity) +{ + Vector v; + RenderObject *r = robj(L); + if (r) + v = r->gravity; + luaReturnVec2(v.x, v.y); +} + luaFunc(obj_getCollideRadius) { RenderObject *r = robj(L); @@ -1738,6 +1758,8 @@ luaFunc(quad_getBorderAlpha) RO_FUNC(getter, prefix, addInternalVel ) \ RO_FUNC(getter, prefix, isInternalVelIn) \ RO_FUNC(getter, prefix, getInternalVelLen) \ + RO_FUNC(getter, prefix, setGravity ) \ + RO_FUNC(getter, prefix, getGravity ) \ RO_FUNC(getter, prefix, getCollideRadius) \ RO_FUNC(getter, prefix, setCollideRadius) \ RO_FUNC(getter, prefix, getNormal ) \