Add evt.beforesim and evt.aftersim for running code only when simulation advances
Only triggered when simulation is unpaused or simulating via subframe debugging. beforesim is the location where most vanilla sim handlers are run.
This commit is contained in:
parent
299781bf13
commit
63661a752c
@ -104,19 +104,31 @@ public:
|
||||
int PushToStack(lua_State * l) override;
|
||||
};
|
||||
|
||||
class TickEvent: public Event
|
||||
class TickEvent : public Event
|
||||
{
|
||||
public:
|
||||
int PushToStack(lua_State *l) override { return 0; }
|
||||
};
|
||||
|
||||
class BlurEvent: public Event
|
||||
class BlurEvent : public Event
|
||||
{
|
||||
public:
|
||||
int PushToStack(lua_State *l) override { return 0; }
|
||||
};
|
||||
|
||||
class CloseEvent: public Event
|
||||
class CloseEvent : public Event
|
||||
{
|
||||
public:
|
||||
int PushToStack(lua_State *l) override { return 0; }
|
||||
};
|
||||
|
||||
class BeforeSimEvent : public Event
|
||||
{
|
||||
public:
|
||||
int PushToStack(lua_State *l) override { return 0; }
|
||||
};
|
||||
|
||||
class AfterSimEvent : public Event
|
||||
{
|
||||
public:
|
||||
int PushToStack(lua_State *l) override { return 0; }
|
||||
@ -136,7 +148,9 @@ public:
|
||||
mousewheel,
|
||||
tick,
|
||||
blur,
|
||||
close
|
||||
close,
|
||||
beforesim,
|
||||
aftersim,
|
||||
};
|
||||
|
||||
static int RegisterEventHook(lua_State *l, ByteString eventName);
|
||||
|
@ -4077,6 +4077,8 @@ void LuaScriptInterface::initEventAPI()
|
||||
lua_pushinteger(l, LuaEvents::tick); lua_setfield(l, -2, "tick");
|
||||
lua_pushinteger(l, LuaEvents::blur); lua_setfield(l, -2, "blur");
|
||||
lua_pushinteger(l, LuaEvents::close); lua_setfield(l, -2, "close");
|
||||
lua_pushinteger(l, LuaEvents::beforesim); lua_setfield(l, -2, "beforesim");
|
||||
lua_pushinteger(l, LuaEvents::aftersim); lua_setfield(l, -2, "aftersim");
|
||||
}
|
||||
|
||||
int LuaScriptInterface::event_register(lua_State * l)
|
||||
|
@ -4988,6 +4988,8 @@ void Simulation::BeforeSim()
|
||||
{
|
||||
if (!sys_pause||framerender)
|
||||
{
|
||||
luacon_ci->HandleEvent(LuaEvents::beforesim, new BeforeSimEvent());
|
||||
|
||||
air->update_air();
|
||||
|
||||
if(aheat_enable)
|
||||
@ -5186,6 +5188,8 @@ void Simulation::AfterSim()
|
||||
Element_EMP_Trigger(this, emp_trigger_count);
|
||||
emp_trigger_count = 0;
|
||||
}
|
||||
|
||||
luacon_ci->HandleEvent(LuaEvents::aftersim, new AfterSimEvent());
|
||||
}
|
||||
|
||||
Simulation::~Simulation()
|
||||
|
Reference in New Issue
Block a user