Add ClientObjectRef:remove and return true in on_object_add callback to remove newly added object
This commit is contained in:
parent
fb4815c660
commit
950d2c9b3e
@ -822,8 +822,11 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||
setNodeLight(m_last_light);
|
||||
updateMeshCulling();
|
||||
|
||||
if (m_client->modsLoaded())
|
||||
m_client->getScript()->on_object_add(m_id);
|
||||
if (m_client->modsLoaded() && m_client->getScript()->on_object_add(m_id)) {
|
||||
removeFromScene(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_client->modsLoaded())
|
||||
m_client->getScript()->on_object_properties_change(m_id);
|
||||
|
@ -323,7 +323,7 @@ void ScriptApiClient::on_object_hp_change(s16 id)
|
||||
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
|
||||
}
|
||||
|
||||
void ScriptApiClient::on_object_add(s16 id)
|
||||
bool ScriptApiClient::on_object_add(s16 id)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
@ -335,7 +335,8 @@ void ScriptApiClient::on_object_add(s16 id)
|
||||
push_objectRef(L, id);
|
||||
|
||||
// Call functions
|
||||
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
|
||||
runCallbacks(1, RUN_CALLBACKS_MODE_OR);
|
||||
return readParam<bool>(L, -1);
|
||||
}
|
||||
|
||||
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
bool on_spawn_particle(struct ParticleParameters param);
|
||||
void on_object_properties_change(s16 id);
|
||||
void on_object_hp_change(s16 id);
|
||||
void on_object_add(s16 id);
|
||||
bool on_object_add(s16 id);
|
||||
|
||||
bool on_inventory_open(Inventory *inventory);
|
||||
void open_enderchest();
|
||||
|
@ -338,4 +338,5 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
|
||||
luamethod(ClientObjectRef, get_hp),
|
||||
luamethod(ClientObjectRef, get_max_hp), luamethod(ClientObjectRef, punch),
|
||||
luamethod(ClientObjectRef, rightclick),
|
||||
luamethod(ClientObjectRef, remove),
|
||||
luamethod(ClientObjectRef, set_nametag_images), {0, 0}};
|
||||
|
Loading…
x
Reference in New Issue
Block a user