mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fixed love.keyboard.setKeyRepeat, fixed issues with Body:getWhatever, and made the save directory settable.
This commit is contained in:
@@ -60,10 +60,6 @@ namespace physfs
|
|||||||
if(!isInited)
|
if(!isInited)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check whether save directory is already set.
|
|
||||||
if(!save_identity.empty() || PHYSFS_getWriteDir() != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Store the save directory.
|
// Store the save directory.
|
||||||
save_identity = std::string(ident);
|
save_identity = std::string(ident);
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ namespace devil
|
|||||||
ilBindImage(image);
|
ilBindImage(image);
|
||||||
|
|
||||||
ilTexImage(width, height, 1, bpp, IL_RGBA, IL_UNSIGNED_BYTE, 0);
|
ilTexImage(width, height, 1, bpp, IL_RGBA, IL_UNSIGNED_BYTE, 0);
|
||||||
|
|
||||||
|
// Set to black.
|
||||||
|
memset((void*)ilGetData(), 0, width*height*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageData::ImageData(int width, int height, void *data)
|
ImageData::ImageData(int width, int height, void *data)
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ namespace keyboard
|
|||||||
KEY_MAX_ENUM = 512
|
KEY_MAX_ENUM = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int DEFAULT = 0;
|
static const int DEFAULT = -1;
|
||||||
|
|
||||||
virtual ~Keyboard(){}
|
virtual ~Keyboard(){}
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,10 @@ namespace sdl
|
|||||||
|
|
||||||
void Keyboard::setKeyRepeat(int delay, int interval) const
|
void Keyboard::setKeyRepeat(int delay, int interval) const
|
||||||
{
|
{
|
||||||
if(delay == DEFAULT)
|
delay = (delay == DEFAULT) ? SDL_DEFAULT_REPEAT_DELAY : delay;
|
||||||
delay = SDL_DEFAULT_REPEAT_DELAY;
|
interval = (interval == DEFAULT) ? SDL_DEFAULT_REPEAT_INTERVAL : interval;
|
||||||
|
|
||||||
if(interval == DEFAULT)
|
SDL_EnableKeyRepeat(delay, interval);
|
||||||
interval = SDL_DEFAULT_REPEAT_INTERVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Keyboard::getKeyRepeatDelay() const
|
int Keyboard::getKeyRepeatDelay() const
|
||||||
|
|||||||
@@ -46,13 +46,14 @@ namespace sdl
|
|||||||
|
|
||||||
int w_setKeyRepeat(lua_State * L)
|
int w_setKeyRepeat(lua_State * L)
|
||||||
{
|
{
|
||||||
if(lua_gettop(L) == 0)
|
if(lua_gettop(L) == 0)
|
||||||
{
|
{
|
||||||
instance->setKeyRepeat(0, 0);
|
// Disables key repeat.
|
||||||
return 0;
|
instance->setKeyRepeat(0, 0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance->setKeyRepeat(luaL_checkint(L, 1), luaL_checkint(L, 2));
|
instance->setKeyRepeat(luaL_optint(L, 1, Keyboard::DEFAULT), luaL_optint(L, 2, Keyboard::DEFAULT));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,14 +58,18 @@ namespace box2d
|
|||||||
return world->scaleUp(body->GetPosition().y);
|
return world->scaleUp(body->GetPosition().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getPosition(lua_State * L)
|
void Body::getPosition(float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
return pushVector(L, world->scaleUp(body->GetPosition()));
|
b2Vec2 v = world->scaleUp(body->GetPosition());
|
||||||
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLinearVelocity(lua_State * L)
|
void Body::getLinearVelocity(float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
return pushVector(L, world->scaleUp(body->GetLinearVelocity()));
|
b2Vec2 v = world->scaleUp(body->GetLinearVelocity());
|
||||||
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Body::getAngle()
|
float Body::getAngle()
|
||||||
@@ -73,14 +77,18 @@ namespace box2d
|
|||||||
return body->GetAngle();
|
return body->GetAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getWorldCenter(lua_State * L)
|
void Body::getWorldCenter(float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
return pushVector(L, world->scaleUp(body->GetWorldCenter()));
|
b2Vec2 v = world->scaleUp(body->GetWorldCenter());
|
||||||
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLocalCenter(lua_State * L)
|
void Body::getLocalCenter(float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
return pushVector(L, world->scaleUp(body->GetLocalCenter()));
|
b2Vec2 v = world->scaleUp(body->GetLocalCenter());
|
||||||
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Body::getAngularVelocity() const
|
float Body::getAngularVelocity() const
|
||||||
@@ -187,40 +195,46 @@ namespace box2d
|
|||||||
body->SetMass(&massData);
|
body->SetMass(&massData);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getWorldPoint(lua_State * L)
|
void Body::getWorldPoint(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetWorldPoint(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetWorldPoint(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getWorldVector(lua_State * L)
|
void Body::getWorldVector(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetWorldVector(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetWorldVector(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLocalPoint(lua_State * L)
|
void Body::getLocalPoint(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetLocalPoint(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetLocalPoint(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLocalVector(lua_State * L)
|
void Body::getLocalVector(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetLocalVector(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetLocalVector(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLinearVelocityFromWorldPoint(lua_State * L)
|
void Body::getLinearVelocityFromWorldPoint(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetLinearVelocityFromWorldPoint(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetLinearVelocityFromWorldPoint(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Body::getLinearVelocityFromLocalPoint(lua_State * L)
|
void Body::getLinearVelocityFromLocalPoint(float x, float y, float & x_o, float & y_o)
|
||||||
{
|
{
|
||||||
b2Vec2 v = world->scaleDown(getVector(L));
|
b2Vec2 v = world->scaleUp(body->GetLinearVelocityFromLocalPoint(world->scaleDown(b2Vec2(x, y))));
|
||||||
return pushVector(L, world->scaleUp(body->GetLinearVelocityFromLocalPoint(v)));
|
x_o = v.x;
|
||||||
|
y_o = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Body::isBullet() const
|
bool Body::isBullet() const
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#define LOVE_PHYSICS_BOX2D_BODY_H
|
#define LOVE_PHYSICS_BOX2D_BODY_H
|
||||||
|
|
||||||
// LOVE
|
// LOVE
|
||||||
|
#include <common/math.h>
|
||||||
#include <common/runtime.h>
|
#include <common/runtime.h>
|
||||||
#include <common/Object.h>
|
#include <common/Object.h>
|
||||||
|
|
||||||
@@ -93,17 +94,15 @@ namespace box2d
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current position of the Body.
|
* Gets the current position of the Body.
|
||||||
* @returns The current x-position.
|
* @returns The current position.
|
||||||
* @returns The current y-position.
|
|
||||||
**/
|
**/
|
||||||
int getPosition(lua_State * L);
|
void getPosition(float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the velocity in the current center of mass.
|
* Gets the velocity in the current center of mass.
|
||||||
* @returns The x-component of the velocity.
|
* @returns The velocity in the current center of mass.
|
||||||
* @returns The y-component of the velocity.
|
|
||||||
**/
|
**/
|
||||||
int getLinearVelocity(lua_State * L);
|
void getLinearVelocity(float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current center of mass for the Body in world
|
* The current center of mass for the Body in world
|
||||||
@@ -111,7 +110,7 @@ namespace box2d
|
|||||||
* @returns The x-component of the point.
|
* @returns The x-component of the point.
|
||||||
* @returns The y-component of the point.
|
* @returns The y-component of the point.
|
||||||
**/
|
**/
|
||||||
int getWorldCenter(lua_State * L);
|
void getWorldCenter(float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current center of mass for the Body in local
|
* The current center of mass for the Body in local
|
||||||
@@ -119,7 +118,7 @@ namespace box2d
|
|||||||
* @returns The x-component of the point.
|
* @returns The x-component of the point.
|
||||||
* @returns The y-component of the point.
|
* @returns The y-component of the point.
|
||||||
**/
|
**/
|
||||||
int getLocalCenter(lua_State * L);
|
void getLocalCenter(float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current Body spin. (Angular velocity).
|
* Get the current Body spin. (Angular velocity).
|
||||||
@@ -233,7 +232,7 @@ namespace box2d
|
|||||||
* @returns The x-coordinate of the point in world coordinates.
|
* @returns The x-coordinate of the point in world coordinates.
|
||||||
* @returns The y-coordinate of the point in world coordinates.
|
* @returns The y-coordinate of the point in world coordinates.
|
||||||
**/
|
**/
|
||||||
int getWorldPoint(lua_State * L);
|
void getWorldPoint(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a vector (x, y) from local coordinates
|
* Transforms a vector (x, y) from local coordinates
|
||||||
@@ -243,7 +242,7 @@ namespace box2d
|
|||||||
* @returns The x-coordinate of the vector in world coordinates.
|
* @returns The x-coordinate of the vector in world coordinates.
|
||||||
* @returns The y-coordinate of the vector in world coordinates.
|
* @returns The y-coordinate of the vector in world coordinates.
|
||||||
**/
|
**/
|
||||||
int getWorldVector(lua_State * L);
|
void getWorldVector(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a point (x, y) from world coordinates
|
* Transforms a point (x, y) from world coordinates
|
||||||
@@ -253,7 +252,7 @@ namespace box2d
|
|||||||
* @returns The x-coordinate of the point in local coordinates.
|
* @returns The x-coordinate of the point in local coordinates.
|
||||||
* @returns The y-coordinate of the point in local coordinates.
|
* @returns The y-coordinate of the point in local coordinates.
|
||||||
**/
|
**/
|
||||||
int getLocalPoint(lua_State * L);
|
void getLocalPoint(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a vector (x, y) from world coordinates
|
* Transforms a vector (x, y) from world coordinates
|
||||||
@@ -263,7 +262,7 @@ namespace box2d
|
|||||||
* @returns The x-coordinate of the vector in local coordinates.
|
* @returns The x-coordinate of the vector in local coordinates.
|
||||||
* @returns The y-coordinate of the vector in local coordinates.
|
* @returns The y-coordinate of the vector in local coordinates.
|
||||||
**/
|
**/
|
||||||
int getLocalVector(lua_State * L);
|
void getLocalVector(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the velocity on the Body for the given world point.
|
* Gets the velocity on the Body for the given world point.
|
||||||
@@ -272,7 +271,7 @@ namespace box2d
|
|||||||
* @returns The x-component of the velocity vector.
|
* @returns The x-component of the velocity vector.
|
||||||
* @returns The y-component of the velocity vector.
|
* @returns The y-component of the velocity vector.
|
||||||
**/
|
**/
|
||||||
int getLinearVelocityFromWorldPoint(lua_State * L);
|
void getLinearVelocityFromWorldPoint(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the velocity on the Body for the given local point.
|
* Gets the velocity on the Body for the given local point.
|
||||||
@@ -281,7 +280,7 @@ namespace box2d
|
|||||||
* @returns The x-component of the velocity vector.
|
* @returns The x-component of the velocity vector.
|
||||||
* @returns The y-component of the velocity vector.
|
* @returns The y-component of the velocity vector.
|
||||||
**/
|
**/
|
||||||
int getLinearVelocityFromLocalPoint(lua_State * L);
|
void getLinearVelocityFromLocalPoint(float x, float y, float & x_o, float & y_o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the Body is a bullet, false otherwise.
|
* Returns true if the Body is a bullet, false otherwise.
|
||||||
|
|||||||
@@ -55,25 +55,49 @@ namespace box2d
|
|||||||
int w_Body_getPosition(lua_State * L)
|
int w_Body_getPosition(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getPosition(L);
|
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getPosition(x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLinearVelocity(lua_State * L)
|
int w_Body_getLinearVelocity(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLinearVelocity(L);
|
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLinearVelocity(x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getWorldCenter(lua_State * L)
|
int w_Body_getWorldCenter(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getWorldCenter(L);
|
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getWorldCenter(x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLocalCenter(lua_State * L)
|
int w_Body_getLocalCenter(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLocalCenter(L);
|
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLocalCenter(x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getAngularVelocity(lua_State * L)
|
int w_Body_getAngularVelocity(lua_State * L)
|
||||||
@@ -228,37 +252,85 @@ namespace box2d
|
|||||||
int w_Body_getWorldPoint(lua_State * L)
|
int w_Body_getWorldPoint(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getWorldPoint(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getWorldPoint(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getWorldVector(lua_State * L)
|
int w_Body_getWorldVector(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getWorldVector(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getWorldVector(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLocalPoint(lua_State * L)
|
int w_Body_getLocalPoint(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLocalPoint(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLocalPoint(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLocalVector(lua_State * L)
|
int w_Body_getLocalVector(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLocalVector(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLocalVector(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLinearVelocityFromWorldPoint(lua_State * L)
|
int w_Body_getLinearVelocityFromWorldPoint(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLinearVelocityFromWorldPoint(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLinearVelocityFromWorldPoint(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_getLinearVelocityFromLocalPoint(lua_State * L)
|
int w_Body_getLinearVelocityFromLocalPoint(lua_State * L)
|
||||||
{
|
{
|
||||||
Body * t = luax_checkbody(L, 1);
|
Body * t = luax_checkbody(L, 1);
|
||||||
return t->getLinearVelocityFromLocalPoint(L);
|
|
||||||
|
float x = (float)luaL_checknumber(L, 2);
|
||||||
|
float y = (float)luaL_checknumber(L, 3);
|
||||||
|
float x_o, y_o;
|
||||||
|
t->getLinearVelocityFromLocalPoint(x, y, x_o, y_o);
|
||||||
|
lua_pushnumber(L, x_o);
|
||||||
|
lua_pushnumber(L, y_o);
|
||||||
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Body_isBullet(lua_State * L)
|
int w_Body_isBullet(lua_State * L)
|
||||||
|
|||||||
+16
-2
@@ -60,7 +60,18 @@ end
|
|||||||
|
|
||||||
-- Returns the leaf of a full path.
|
-- Returns the leaf of a full path.
|
||||||
function love.path.leaf(p)
|
function love.path.leaf(p)
|
||||||
|
local a = 1
|
||||||
|
local last = p
|
||||||
|
|
||||||
|
while a do
|
||||||
|
a = string.find(p, "/", a+1)
|
||||||
|
|
||||||
|
if a then
|
||||||
|
last = string.sub(p, a+1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return last
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Finds the key in the table with the lowest integral index. The lowest
|
-- Finds the key in the table with the lowest integral index. The lowest
|
||||||
@@ -113,7 +124,10 @@ function love.boot()
|
|||||||
|
|
||||||
if arg and arg[1] then
|
if arg and arg[1] then
|
||||||
love.filesystem.init(love.path.getfull(love.arg.getLow(arg)))
|
love.filesystem.init(love.path.getfull(love.arg.getLow(arg)))
|
||||||
if not pcall(love.filesystem.setSource, love.path.getfull(arg[1])) then
|
local full_source = love.path.getfull(arg[1])
|
||||||
|
local leaf = love.path.leaf(full_source)
|
||||||
|
love.filesystem.setIdentity(leaf)
|
||||||
|
if not pcall(love.filesystem.setSource, full_source) then
|
||||||
love.nogame()
|
love.nogame()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user