1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-07 17:11:56 +00:00

Minor Lua changes:

+ node_setEmitter(name)
+ node_getEmitter()
* obj_setTexture() returns bool now
This commit is contained in:
fgenesis 2015-06-08 02:14:45 +02:00
parent b71c21a0b3
commit 1af3a580ed
3 changed files with 43 additions and 11 deletions

View file

@ -450,14 +450,23 @@ void Path::refreshScript()
//core->removeRenderObject(&emitter, Core::DO_NOT_DESTROY_RENDER_OBJECT); //core->removeRenderObject(&emitter, Core::DO_NOT_DESTROY_RENDER_OBJECT);
//core->getTopStateData()->addRenderObject(&emitter, LR_PARTICLES); //core->getTopStateData()->addRenderObject(&emitter, LR_PARTICLES);
if (emitter) setEmitter(particleEffect);
{ }
emitter->safeKill(); }
emitter = 0;
} void Path::setEmitter(const std::string& name)
{
if (emitter)
{
emitter->safeKill();
emitter = 0;
}
if(!name.empty())
{
emitter = new ParticleEffect; emitter = new ParticleEffect;
emitter->load(particleEffect); emitter->load(name);
emitter->start(); if(active)
emitter->start();
if (!nodes.empty()) if (!nodes.empty())
{ {
emitter->position = nodes[0].position; emitter->position = nodes[0].position;

View file

@ -89,6 +89,7 @@ public:
void update(float dt); void update(float dt);
void setActive(bool v); void setActive(bool v);
bool action(int id, int state); bool action(int id, int state);
void setEmitter(const std::string& name);
PathNode *getPathNode(int idx); PathNode *getPathNode(int idx);
bool isCoordinateInside(const Vector &pos, int rad=0); bool isCoordinateInside(const Vector &pos, int rad=0);

View file

@ -1113,9 +1113,7 @@ luaFunc(obj_setBlendType)
luaFunc(obj_setTexture) luaFunc(obj_setTexture)
{ {
RenderObject *r = robj(L); RenderObject *r = robj(L);
if (r) luaReturnBool(r ? r->setTexture(getString(L, 2)) : false);
r->setTexture(getString(L, 2));
luaReturnNil();
} }
luaFunc(obj_getTexture) luaFunc(obj_getTexture)
@ -4916,6 +4914,21 @@ luaFunc(getStringFlag)
luaReturnStr(dsq->continuity.getStringFlag(getString(L, 1)).c_str()); luaReturnStr(dsq->continuity.getStringFlag(getString(L, 1)).c_str());
} }
luaFunc(node_setEmitter)
{
Path *p = path(L);
if(p)
p->setEmitter(getString(L, 2));
luaReturnPtr(p->emitter);
}
luaFunc(node_getEmitter)
{
Path *p = path(L);
luaReturnPtr(p ? p->emitter : NULL);
}
luaFunc(node_setActive) luaFunc(node_setActive)
{ {
Path *p = path(L); Path *p = path(L);
@ -4923,6 +4936,13 @@ luaFunc(node_setActive)
if (p) if (p)
{ {
p->active = v; p->active = v;
if(p->emitter)
{
if(v)
p->emitter->start();
else
p->emitter->stop();
}
} }
luaReturnNil(); luaReturnNil();
} }
@ -6489,7 +6509,7 @@ luaFunc(playSfx)
if (sfx.vol <= 0) if (sfx.vol <= 0)
sfx.vol = 1; sfx.vol = 1;
sfx.loops = lua_tointeger(L, 4); sfx.loops = lua_tointeger(L, 4);
if(lua_isnumber(L, 6) && lua_isnumber(L, 7)) if(lua_isnumber(L, 5) && lua_isnumber(L, 6))
{ {
sfx.x = lua_tonumber(L, 5); sfx.x = lua_tonumber(L, 5);
sfx.y = lua_tonumber(L, 6); sfx.y = lua_tonumber(L, 6);
@ -9999,6 +10019,8 @@ static const struct {
luaRegister(node_setActive), luaRegister(node_setActive),
luaRegister(node_isActive), luaRegister(node_isActive),
luaRegister(node_setEmitter),
luaRegister(node_getEmitter),
luaRegister(setSceneColor), luaRegister(setSceneColor),