mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 22:44:32 +00:00
Implement node messaging (node_msg() function); there is no reason entities have this but nodes do not.
Also made node script error messages a bit nicer.
This commit is contained in:
parent
3ad6eedd37
commit
76cfa6fe33
3 changed files with 41 additions and 7 deletions
|
@ -235,7 +235,7 @@ void Path::song(SongType songType)
|
||||||
if (!script->call("song", this, int(songType)))
|
if (!script->call("song", this, int(songType)))
|
||||||
{
|
{
|
||||||
songFunc = false;
|
songFunc = false;
|
||||||
debugLog("Path [" + name + "] " + script->getLastError());
|
luaDebugMsg("song", script->getLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ void Path::songNote(int note)
|
||||||
if (!script->call("songNote", this, note))
|
if (!script->call("songNote", this, note))
|
||||||
{
|
{
|
||||||
songNoteFunc = false;
|
songNoteFunc = false;
|
||||||
debugLog("Path [" + name + "] " + script->getLastError() + " songNote");
|
luaDebugMsg("songNote", script->getLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ void Path::songNoteDone(int note, float len)
|
||||||
if (!script->call("songNoteDone", this, note, len))
|
if (!script->call("songNoteDone", this, note, len))
|
||||||
{
|
{
|
||||||
songNoteDoneFunc = false;
|
songNoteDoneFunc = false;
|
||||||
debugLog("Path [" + name + "] " + script->getLastError() + " songNoteDone");
|
luaDebugMsg("songNoteDone", script->getLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ void Path::init()
|
||||||
{
|
{
|
||||||
if (!script->call("init", this))
|
if (!script->call("init", this))
|
||||||
{
|
{
|
||||||
debugLog(name + " : " + script->getLastError() + " init");
|
luaDebugMsg("init", script->getLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ void Path::update(float dt)
|
||||||
{
|
{
|
||||||
if (!script->call("update", this, dt))
|
if (!script->call("update", this, dt))
|
||||||
{
|
{
|
||||||
debugLog(name + " : " + script->getLastError() + " update");
|
luaDebugMsg("update", script->getLastError());
|
||||||
updateFunction = false;
|
updateFunction = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ bool Path::action(int id, int state)
|
||||||
{
|
{
|
||||||
bool dontRemove = true;
|
bool dontRemove = true;
|
||||||
if (!script->call("action", this, id, state, &dontRemove))
|
if (!script->call("action", this, id, state, &dontRemove))
|
||||||
debugLog(name + " : " + script->getLastError() + " action");
|
luaDebugMsg("action", script->getLastError());
|
||||||
return dontRemove;
|
return dontRemove;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -653,7 +653,7 @@ void Path::activate(Entity *e)
|
||||||
{
|
{
|
||||||
if (!script->call("activate", this, e))
|
if (!script->call("activate", this, e))
|
||||||
{
|
{
|
||||||
debugLog(name + " : " + script->getLastError() + " activate");
|
luaDebugMsg("activate", script->getLastError());
|
||||||
activateFunction = false;
|
activateFunction = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -704,3 +704,20 @@ void Path::addNode(int idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Path::messageVariadic(lua_State *L, int nparams)
|
||||||
|
{
|
||||||
|
if (script)
|
||||||
|
{
|
||||||
|
int res = script->callVariadic("msg", L, nparams, this);
|
||||||
|
if (res < 0)
|
||||||
|
luaDebugMsg("msg", script->getLastError());
|
||||||
|
else
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Path::luaDebugMsg(const std::string &func, const std::string &msg)
|
||||||
|
{
|
||||||
|
debugLog("luaScriptError: Path [" + name + "]: " + func + " : " + msg);
|
||||||
|
}
|
||||||
|
|
|
@ -149,6 +149,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
void parseWarpNodeData(const std::string &dataString);
|
void parseWarpNodeData(const std::string &dataString);
|
||||||
|
|
||||||
|
int messageVariadic(lua_State *L, int nparams);
|
||||||
|
void luaDebugMsg(const std::string &func, const std::string &msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4785,6 +4785,19 @@ luaFunc(entity_msg)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(node_msg)
|
||||||
|
{
|
||||||
|
Path *p = path(L);
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
// pass everything on the stack except the entity pointer
|
||||||
|
int res = p->messageVariadic(L, lua_gettop(L) - 1);
|
||||||
|
if (res >= 0)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
luaReturnNil();
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(entity_updateCurrents)
|
luaFunc(entity_updateCurrents)
|
||||||
{
|
{
|
||||||
Entity *e = entity(L);
|
Entity *e = entity(L);
|
||||||
|
@ -8335,6 +8348,7 @@ static const struct {
|
||||||
luaRegister(entity_getMaxHealth),
|
luaRegister(entity_getMaxHealth),
|
||||||
luaRegister(entity_pushTarget),
|
luaRegister(entity_pushTarget),
|
||||||
luaRegister(entity_msg),
|
luaRegister(entity_msg),
|
||||||
|
luaRegister(node_msg),
|
||||||
luaRegister(entity_updateMovement),
|
luaRegister(entity_updateMovement),
|
||||||
luaRegister(entity_updateCurrents),
|
luaRegister(entity_updateCurrents),
|
||||||
luaRegister(entity_updateLocalWarpAreas),
|
luaRegister(entity_updateLocalWarpAreas),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue