1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-04 10:34:01 +00:00

Little update fixing some minor things

Rename msg() Lua function to screenMessage().
Identify an unused script.
This commit is contained in:
fgenesis 2017-01-20 02:20:58 +01:00
parent e35a309732
commit b52ff75c95
3 changed files with 28 additions and 27 deletions

View file

@ -64,15 +64,15 @@ static std::string getSceneFilename(const std::string &scene)
return ""; return "";
} }
Ingredient *Game::getNearestIngredient(const Vector &pos, int radius) Ingredient *Game::getNearestIngredient(const Vector &pos, float radius)
{ {
int closest = -1; int closest = -1;
int r2 = sqr(radius); float r2 = sqr(radius);
Ingredient *returnIngredient = 0; Ingredient *returnIngredient = 0;
for (Ingredients::iterator i = ingredients.begin(); i != ingredients.end(); i++) for (Ingredients::iterator i = ingredients.begin(); i != ingredients.end(); i++)
{ {
int len = (pos - (*i)->position).getSquaredLength2D(); float len = (pos - (*i)->position).getSquaredLength2D();
if (len <= r2 && (closest == - 1 || len < closest)) if (len <= r2 && (closest == - 1 || len < closest))
{ {
closest = len; closest = len;

View file

@ -460,7 +460,7 @@ public:
Ingredient* spawnIngredient(const std::string &ing, const Vector &pos, int times=1, int out=0); Ingredient* spawnIngredient(const std::string &ing, const Vector &pos, int times=1, int out=0);
void spawnIngredientFromEntity(Entity *ent, IngredientData *data); void spawnIngredientFromEntity(Entity *ent, IngredientData *data);
Ingredient *getNearestIngredient(const Vector &pos, int radius); Ingredient *getNearestIngredient(const Vector &pos, float radius);
Entity *getNearestEntity(const Vector &pos, int radius, Entity *ignore = 0, EntityType et=ET_NOTYPE, DamageType dt=DT_NONE, int lrStart=-1, int lrEnd=-1); Entity *getNearestEntity(const Vector &pos, int radius, Entity *ignore = 0, EntityType et=ET_NOTYPE, DamageType dt=DT_NONE, int lrStart=-1, int lrEnd=-1);
Script *cookingScript; Script *cookingScript;

View file

@ -1176,10 +1176,10 @@ luaFunc(obj_setTexture)
luaFunc(obj_getTexture) luaFunc(obj_getTexture)
{ {
RenderObject *r = robj(L); RenderObject *r = robj(L);
if (r && r->texture) if (r && r->texture)
luaReturnStr(r->texture->name.c_str()); luaReturnStr(r->texture->name.c_str());
luaReturnStr(""); luaReturnStr("");
} }
luaFunc(obj_delete) luaFunc(obj_delete)
@ -2187,8 +2187,6 @@ luaFunc(getNoteColor)
luaFunc(getRandNote) luaFunc(getRandNote)
{ {
luaReturnNum(dsq->getRandNote()); luaReturnNum(dsq->getRandNote());
} }
@ -4572,7 +4570,7 @@ luaFunc(entity_getAnimationLoop)
luaFunc(entity_move) luaFunc(entity_move)
{ {
Entity *e = entity(L); Entity *e = entity(L);
//bool ease = lua_tointeger(L, 5); //bool ease = lua_tointeger(L, 5);
Vector p(lua_tonumber(L, 2), lua_tonumber(L, 3)); Vector p(lua_tonumber(L, 2), lua_tonumber(L, 3));
if (getBool(L, 6)) if (getBool(L, 6))
p = e->position + p; p = e->position + p;
@ -5386,7 +5384,8 @@ luaFunc(centerText)
luaReturnNil(); luaReturnNil();
} }
luaFunc(msg) // this used to be msg(), but this is already an interface function name
luaFunc(screenMessage)
{ {
dsq->screenMessage(getString(L, 1)); dsq->screenMessage(getString(L, 1));
luaReturnNil(); luaReturnNil();
@ -7467,14 +7466,14 @@ luaFunc(entity_getID)
luaFunc(getEntityByID) luaFunc(getEntityByID)
{ {
debugLog("Calling getEntityByID"); //debugLog("Calling getEntityByID");
int v = lua_tointeger(L, 1); int v = lua_tointeger(L, 1);
Entity *found = 0; Entity *found = 0;
if (v) if (v)
{ {
std::ostringstream os; //std::ostringstream os;
os << "searching for entity with id: " << v; //os << "searching for entity with id: " << v;
debugLog(os.str()); //debugLog(os.str());
FOR_ENTITIES(i) FOR_ENTITIES(i)
{ {
Entity *e = *i; Entity *e = *i;
@ -7484,7 +7483,7 @@ luaFunc(getEntityByID)
break; break;
} }
} }
if (!found) /*if (!found)
{ {
std::ostringstream os; std::ostringstream os;
os << "entity with id: " << v << " not found!"; os << "entity with id: " << v << " not found!";
@ -7495,12 +7494,12 @@ luaFunc(getEntityByID)
std::ostringstream os; std::ostringstream os;
os << "Found: " << found->name; os << "Found: " << found->name;
debugLog(os.str()); debugLog(os.str());
} }*/
} }
else /*else
{ {
debugLog("entity ID was 0"); debugLog("entity ID was 0");
} }*/
luaReturnPtr(found); luaReturnPtr(found);
} }
@ -7729,7 +7728,7 @@ luaFunc(getNearestEntity)
Vector p(lua_tonumber(L, 1), lua_tonumber(L, 2)); Vector p(lua_tonumber(L, 1), lua_tonumber(L, 2));
int radius = lua_tointeger(L, 3); int radius = lua_tointeger(L, 3);
Entity *ignore = lua_isuserdata(L, 4) ? entity(L, 4) : NULL; Entity *ignore = lua_isuserdata(L, 4) ? entity(L, 4) : NULL;
//EntityType et = lua_isnumber(L, 5) ? (EntityType)lua_tointeger(L, 5) : ET_NOTYPE; //EntityType et = lua_isnumber(L, 5) ? (EntityType)lua_tointeger(L, 5) : ET_NOTYPE;
DamageType dt = lua_isnumber(L, 6) ? (DamageType)lua_tointeger(L, 6) : DT_NONE; DamageType dt = lua_isnumber(L, 6) ? (DamageType)lua_tointeger(L, 6) : DT_NONE;
int lrStart = lua_isnumber(L, 7) ? lua_tointeger(L, 7) : -1; int lrStart = lua_isnumber(L, 7) ? lua_tointeger(L, 7) : -1;
int lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1; int lrEnd = lua_isnumber(L, 8) ? lua_tointeger(L, 8) : -1;
@ -8156,13 +8155,15 @@ luaFunc(entity_getTarget)
luaFunc(entity_getTargetPositionX) luaFunc(entity_getTargetPositionX)
{ {
Entity *e = entity(L); Entity *e = entity(L);
luaReturnInt(e ? e->getTargetEntity()->position.x : 0); Entity *t = e ? e->getTargetEntity() : NULL;
luaReturnNum(t ? t->position.x : 0.0f);
} }
luaFunc(entity_getTargetPositionY) luaFunc(entity_getTargetPositionY)
{ {
Entity *e = entity(L); Entity *e = entity(L);
luaReturnNum(e ? e->getTargetEntity()->position.y : 0); Entity *t = e ? e->getTargetEntity() : NULL;
luaReturnNum(t ? t->position.y : 0.0f);
} }
luaFunc(entity_isNearObstruction) luaFunc(entity_isNearObstruction)
@ -8995,9 +8996,9 @@ luaFunc(findPathGetStats)
luaFunc(findPathFreeMemory) luaFunc(findPathFreeMemory)
{ {
PathFinding::State *state = *(PathFinding::State**)luaL_checkudata(L, 1, "pathfinder"); PathFinding::State *state = *(PathFinding::State**)luaL_checkudata(L, 1, "pathfinder");
PathFinding::purgeFindPath(state); PathFinding::purgeFindPath(state);
luaReturnNil(); luaReturnNil();
} }
luaFunc(castLine) luaFunc(castLine)
@ -10078,7 +10079,7 @@ static const struct {
luaRegister(isNestedMain), luaRegister(isNestedMain),
luaRegister(msg), luaRegister(screenMessage),
luaRegister(centerText), luaRegister(centerText),
luaRegister(watchForVoice), luaRegister(watchForVoice),