mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Add basic lua 5.3 support
This commit is contained in:
@@ -36,7 +36,7 @@ int w_getDisplayCount(lua_State *L)
|
||||
|
||||
int w_getDisplayName(lua_State *L)
|
||||
{
|
||||
int index = luaL_checkint(L, 1) - 1;
|
||||
int index = (int) luaL_checknumber(L, 1) - 1;
|
||||
|
||||
const char *name = nullptr;
|
||||
luax_catchexcept(L, [&](){ name = instance()->getDisplayName(index); });
|
||||
@@ -54,8 +54,8 @@ static const char *settingName(Window::Setting setting)
|
||||
|
||||
int w_setMode(lua_State *L)
|
||||
{
|
||||
int w = luaL_checkint(L, 1);
|
||||
int h = luaL_checkint(L, 2);
|
||||
int w = (int) luaL_checknumber(L, 1);
|
||||
int h = (int) luaL_checknumber(L, 2);
|
||||
|
||||
if (lua_isnoneornil(L, 3))
|
||||
{
|
||||
@@ -114,8 +114,8 @@ int w_setMode(lua_State *L)
|
||||
settings.useposition = !(lua_isnoneornil(L, -2) && lua_isnoneornil(L, -1));
|
||||
if (settings.useposition)
|
||||
{
|
||||
settings.x = luaL_optint(L, -2, 0);
|
||||
settings.y = luaL_optint(L, -1, 0);
|
||||
settings.x = (int) luaL_optnumber(L, -2, 0);
|
||||
settings.y = (int) luaL_optnumber(L, -1, 0);
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
|
||||
@@ -194,7 +194,7 @@ int w_getFullscreenModes(lua_State *L)
|
||||
{
|
||||
int displayindex = 0;
|
||||
if (!lua_isnoneornil(L, 1))
|
||||
displayindex = luaL_checkint(L, 1);
|
||||
displayindex = (int) luaL_checknumber(L, 1);
|
||||
else
|
||||
{
|
||||
int x, y;
|
||||
@@ -271,7 +271,7 @@ int w_getDesktopDimensions(lua_State *L)
|
||||
int width = 0, height = 0;
|
||||
int displayindex = 0;
|
||||
if (!lua_isnoneornil(L, 1))
|
||||
displayindex = luaL_checkint(L, 1);
|
||||
displayindex = (int) luaL_checknumber(L, 1);
|
||||
else
|
||||
{
|
||||
int x, y;
|
||||
@@ -285,12 +285,12 @@ int w_getDesktopDimensions(lua_State *L)
|
||||
|
||||
int w_setPosition(lua_State *L)
|
||||
{
|
||||
int x = luaL_checkint(L, 1);
|
||||
int y = luaL_checkint(L, 2);
|
||||
int x = (int) luaL_checknumber(L, 1);
|
||||
int y = (int) luaL_checknumber(L, 2);
|
||||
|
||||
int displayindex = 0;
|
||||
if (!lua_isnoneornil(L, 3))
|
||||
displayindex = luaL_checkint(L, 3);
|
||||
displayindex = (int) luaL_checknumber(L, 3);
|
||||
else
|
||||
{
|
||||
int x_unused, y_unused;
|
||||
@@ -430,7 +430,7 @@ int w_showMessageBox(lua_State *L)
|
||||
// means we should use the more complex message box API.
|
||||
if (lua_istable(L, 3))
|
||||
{
|
||||
size_t numbuttons = lua_objlen(L, 3);
|
||||
size_t numbuttons = luax_objlen(L, 3);
|
||||
if (numbuttons == 0)
|
||||
return luaL_error(L, "Must have at least one messagebox button.");
|
||||
|
||||
@@ -445,7 +445,7 @@ int w_showMessageBox(lua_State *L)
|
||||
// Optional table entry specifying the button to use when enter is pressed.
|
||||
lua_getfield(L, 3, "enterbutton");
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
data.enterButtonIndex = luaL_checkint(L, -1) - 1;
|
||||
data.enterButtonIndex = (int) luaL_checknumber(L, -1) - 1;
|
||||
else
|
||||
data.enterButtonIndex = 0;
|
||||
lua_pop(L, 1);
|
||||
@@ -453,7 +453,7 @@ int w_showMessageBox(lua_State *L)
|
||||
// Optional table entry specifying the button to use when esc is pressed.
|
||||
lua_getfield(L, 3, "escapebutton");
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
data.escapeButtonIndex = luaL_checkint(L, -1) - 1;
|
||||
data.escapeButtonIndex = (int) luaL_checknumber(L, -1) - 1;
|
||||
else
|
||||
data.escapeButtonIndex = (int) data.buttons.size() - 1;
|
||||
lua_pop(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user