Files
asarium 9651e7dca6 Add more generic scripting callback system
The current scripting hook is pretty simple and straight forward but it
makes a couple of scripting applications harder to implement than
needed.

For example, a lot of scripts need to do some work every frame
for all or some objects. The script needs to manage an internal list of
all the objects that are affected by that list which includes removing
invalid objects to conserve resources. This effectively mirrors what the
engine already does and adds unnecessary overhead.

In these changes I added a generic event system which can be used by any
part of the code for providing callbacks when a specific event occurs.
As an example, I added hooks for the pre- and post-move events to the
object class which are called before and after physics are applied to an
object.

I integrated that feature into the scripting system so now a script can
simply register a function as a callback which will be called whenever
the target event is executed.
2018-07-02 22:56:45 +02:00

25 lines
411 B
C++

//
//
#include "LuaEventCallback.h"
#include "scripting/lua/LuaConvert.h"
using namespace luacpp;
namespace scripting {
namespace api {
namespace util {
void convert_arg(lua_State* L, luacpp::LuaValueList& out, object* objp)
{
LuaValue val;
ade_set_object_with_breed(L, OBJ_INDEX(objp));
convert::popValue(L, val);
out.push_back(val);
}
} // namespace util
} // namespace api
} // namespace scripting