mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-06-08 17:42:05 +00:00
Implement scripts to send msg() to shots
+ Lua func shot_msg()
This commit is contained in:
parent
65248a274f
commit
a477c6d59b
3 changed files with 40 additions and 0 deletions
|
@ -5915,6 +5915,19 @@ luaFunc(node_msg)
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(shot_msg)
|
||||||
|
{
|
||||||
|
Shot *s = getShot(L);
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
// pass everything on the stack except the entity pointer
|
||||||
|
int res = s->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);
|
||||||
|
@ -10366,6 +10379,7 @@ static const struct {
|
||||||
luaRegister(entity_getPushDamage),
|
luaRegister(entity_getPushDamage),
|
||||||
luaRegister(entity_msg),
|
luaRegister(entity_msg),
|
||||||
luaRegister(node_msg),
|
luaRegister(node_msg),
|
||||||
|
luaRegister(shot_msg),
|
||||||
luaRegister(entity_updateMovement),
|
luaRegister(entity_updateMovement),
|
||||||
luaRegister(entity_updateCurrents),
|
luaRegister(entity_updateCurrents),
|
||||||
luaRegister(entity_updateLocalWarpAreas),
|
luaRegister(entity_updateLocalWarpAreas),
|
||||||
|
|
|
@ -933,3 +933,25 @@ void Shot::rotateToVec(Vector addVec, float time, int offsetAngle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shot::luaDebugMsg(const std::string &func, const std::string &msg)
|
||||||
|
{
|
||||||
|
debugLog(std::string("luaScriptError: Shot [") + this->getName() + "]: " + func + " : " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shot::callVariadic(const char* func, lua_State* L, int nparams)
|
||||||
|
{
|
||||||
|
if (script)
|
||||||
|
{
|
||||||
|
int res = script->callVariadic(func, L, nparams, this);
|
||||||
|
if (res < 0)
|
||||||
|
luaDebugMsg(func, script->getLastError());
|
||||||
|
else
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shot::messageVariadic(lua_State * L, int nparams)
|
||||||
|
{
|
||||||
|
return callVariadic("msg", L, nparams);
|
||||||
|
}
|
||||||
|
|
|
@ -124,6 +124,10 @@ public:
|
||||||
inline bool isActive() const { return !dead; }
|
inline bool isActive() const { return !dead; }
|
||||||
inline const char *getName() const { return shotData ? shotData->name.c_str() : ""; }
|
inline const char *getName() const { return shotData ? shotData->name.c_str() : ""; }
|
||||||
|
|
||||||
|
int callVariadic(const char *func, lua_State *L, int nparams);
|
||||||
|
int messageVariadic(lua_State *L, int nparams);
|
||||||
|
void luaDebugMsg(const std::string &func, const std::string &msg);
|
||||||
|
|
||||||
float extraDamage;
|
float extraDamage;
|
||||||
float homingness;
|
float homingness;
|
||||||
float lifeTime;
|
float lifeTime;
|
||||||
|
|
Loading…
Add table
Reference in a new issue