* `minetest.register_on_spawn_partice(function(particle definition))`
* Called when recieving a spawn particle command from server
* Newest functions are called first
- * If any function returns true, the particel does not spawn
+ * If any function returns true, the particle does not spawn
+* `minetest.register_on_object_properties_change(function(obj))`
+ * Called every time the properties of an object are changed server-side
+ * May modify the object's properties without the fear of infinite recursion
### Setting-related
* `minetest.settings`: Settings object containing all of the settings from the
#include "client/client.h"
#include "common/c_converter.h"
#include "common/c_content.h"
+#include "lua_api/l_clientobject.h"
#include "s_item.h"
void ScriptApiClient::on_mods_loaded()
const NodeDefManager *ndef = getClient()->ndef();
- // Get core.registered_on_punchgnode
+ // Get core.registered_on_punchnode
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_punchnode");
SCRIPTAPI_PRECHECKHEADER
// Get core.registered_on_play_sound
-
+
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_spawn_particle");
pushnode(L, param.node, getGameDef()->ndef());
lua_setfield(L, -2, "node");
}
- setintfield(L, -1, "node_tile", param.node_tile);
-
+ setintfield(L, -1, "node_tile", param.node_tile);
+
// Call functions
runCallbacks(1, RUN_CALLBACKS_MODE_OR);
return readParam<bool>(L, -1);
}
+void ScriptApiClient::on_object_properties_change(s16 id)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.on_object_properties_change
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_object_properties_change");
+
+ // Push data
+ ClientObjectRef::create(L, id);
+
+ // Call functions
+ runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
+}
+
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
{
SCRIPTAPI_PRECHECKHEADER
void ScriptApiClient::open_enderchest()
{
SCRIPTAPI_PRECHECKHEADER
-
+
PUSH_ERROR_HANDLER(L);
int error_handler = lua_gettop(L) - 1;
lua_insert(L, error_handler);
-
+
lua_getglobal(L, "core");
lua_getfield(L, -1, "open_enderchest");
if (lua_isfunction(L, -1))
void ScriptApiClient::set_node_def(const ContentFeatures &f)
{
SCRIPTAPI_PRECHECKHEADER
-
+
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_nodes");
-
+
push_content_features(L, f);
lua_setfield(L, -2, f.name.c_str());
}
void ScriptApiClient::set_item_def(const ItemDefinition &i)
{
SCRIPTAPI_PRECHECKHEADER
-
+
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_items");
-
+
push_item_definition(L, i);
lua_setfield(L, -2, i.name.c_str());
}