mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Add basic lua 5.3 support
This commit is contained in:
@@ -263,7 +263,7 @@ int Fixture::rayCast(lua_State *L) const
|
||||
float p2x = Physics::scaleDown((float)luaL_checknumber(L, 3));
|
||||
float p2y = Physics::scaleDown((float)luaL_checknumber(L, 4));
|
||||
float maxFraction = (float)luaL_checknumber(L, 5);
|
||||
int childIndex = (int)luaL_optint(L, 6, 1) - 1; // Convert from 1-based index
|
||||
int childIndex = (int) luaL_optnumber(L, 6, 1) - 1; // Convert from 1-based index
|
||||
b2RayCastInput input;
|
||||
input.p1.Set(p1x, p1y);
|
||||
input.p2.Set(p2x, p2y);
|
||||
@@ -279,7 +279,7 @@ int Fixture::rayCast(lua_State *L) const
|
||||
|
||||
int Fixture::getBoundingBox(lua_State *L) const
|
||||
{
|
||||
int childIndex = (int)luaL_optint(L, 1, 1) - 1; // Convert from 1-based index
|
||||
int childIndex = (int) luaL_optnumber(L, 1, 1) - 1; // Convert from 1-based index
|
||||
b2AABB box = fixture->GetAABB(childIndex);
|
||||
box = Physics::scaleUp(box);
|
||||
lua_pushnumber(L, box.lowerBound.x);
|
||||
|
||||
@@ -97,7 +97,7 @@ int Physics::newPolygonShape(lua_State *L)
|
||||
bool istable = lua_istable(L, 1);
|
||||
|
||||
if (istable)
|
||||
argc = (int) lua_objlen(L, 1);
|
||||
argc = (int) luax_objlen(L, 1);
|
||||
|
||||
if (argc % 2 != 0)
|
||||
return luaL_error(L, "Number of vertex components must be a multiple of two.");
|
||||
@@ -158,7 +158,7 @@ int Physics::newChainShape(lua_State *L)
|
||||
bool istable = lua_istable(L, 2);
|
||||
|
||||
if (istable)
|
||||
argc = (int) lua_objlen(L, 2);
|
||||
argc = (int) luax_objlen(L, 2);
|
||||
|
||||
if (argc % 2 != 0)
|
||||
return luaL_error(L, "Number of vertex components must be a multiple of two.");
|
||||
|
||||
@@ -105,7 +105,7 @@ int Shape::rayCast(lua_State *L) const
|
||||
float x = Physics::scaleDown((float)luaL_checknumber(L, 6));
|
||||
float y = Physics::scaleDown((float)luaL_checknumber(L, 7));
|
||||
float r = (float)luaL_checknumber(L, 8);
|
||||
int childIndex = (int)luaL_optint(L, 9, 1) - 1; // Convert from 1-based index
|
||||
int childIndex = (int) luaL_optnumber(L, 9, 1) - 1; // Convert from 1-based index
|
||||
b2RayCastInput input;
|
||||
input.p1.Set(p1x, p1y);
|
||||
input.p2.Set(p2x, p2y);
|
||||
@@ -125,7 +125,7 @@ int Shape::computeAABB(lua_State *L) const
|
||||
float x = Physics::scaleDown((float)luaL_checknumber(L, 1));
|
||||
float y = Physics::scaleDown((float)luaL_checknumber(L, 2));
|
||||
float r = (float)luaL_checknumber(L, 3);
|
||||
int childIndex = (int)luaL_optint(L, 4, 1) - 1; // Convert from 1-based index
|
||||
int childIndex = (int) luaL_optnumber(L, 4, 1) - 1; // Convert from 1-based index
|
||||
b2Transform transform(b2Vec2(x, y), b2Rot(r));
|
||||
b2AABB box;
|
||||
shape->ComputeAABB(&box, transform, childIndex);
|
||||
|
||||
@@ -55,7 +55,7 @@ int w_ChainShape_setPreviousVertex(lua_State *L)
|
||||
int w_ChainShape_getChildEdge(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
|
||||
int index = (int) luaL_checknumber(L, 2) - 1; // Convert from 1-based index
|
||||
EdgeShape *e = 0;
|
||||
luax_catchexcept(L, [&](){ e = c->getChildEdge(index); });
|
||||
luax_pushtype(L, PHYSICS_EDGE_SHAPE_ID, e);
|
||||
@@ -74,7 +74,7 @@ int w_ChainShape_getVertexCount(lua_State *L)
|
||||
int w_ChainShape_getPoint(lua_State *L)
|
||||
{
|
||||
ChainShape *c = luax_checkchainshape(L, 1);
|
||||
int index = luaL_checkint(L, 2) - 1; // Convert from 1-based index
|
||||
int index = (int) luaL_checknumber(L, 2) - 1; // Convert from 1-based index
|
||||
b2Vec2 v;
|
||||
luax_catchexcept(L, [&](){ v = c->getPoint(index); });
|
||||
lua_pushnumber(L, v.x);
|
||||
|
||||
@@ -165,9 +165,9 @@ int w_Fixture_setFilterData(lua_State *L)
|
||||
{
|
||||
Fixture *t = luax_checkfixture(L, 1);
|
||||
int v[3];
|
||||
v[0] = luaL_checkint(L, 2);
|
||||
v[1] = luaL_checkint(L, 3);
|
||||
v[2] = luaL_checkint(L, 4);
|
||||
v[0] = (int) luaL_checknumber(L, 2);
|
||||
v[1] = (int) luaL_checknumber(L, 3);
|
||||
v[2] = (int) luaL_checknumber(L, 4);
|
||||
t->setFilterData(v);
|
||||
return 0;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ int w_Fixture_getGroupIndex(lua_State *L)
|
||||
int w_Fixture_setGroupIndex(lua_State *L)
|
||||
{
|
||||
Fixture *t = luax_checkfixture(L, 1);
|
||||
int i = luaL_checkint(L, 2);
|
||||
int i = (int) luaL_checknumber(L, 2);
|
||||
t->setGroupIndex(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ int w_getDistance(lua_State *L)
|
||||
|
||||
int w_setMeter(lua_State *L)
|
||||
{
|
||||
int arg1 = luaL_checkint(L, 1);
|
||||
int arg1 = (int) luaL_checknumber(L, 1);
|
||||
luax_catchexcept(L, [&](){ Physics::setMeter(arg1); });
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user