core.registered_on_modchannel_signal, core.register_on_modchannel_signal = make_registration()
core.registered_on_inventory_open, core.register_on_inventory_open = make_registration()
core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration()
+core.registered_on_play_sound, core.register_on_play_sound = make_registration()
* Called when recieving physics_override from server
* Newest functions are called first
* If any function returns true, the physics override does not change
+* `minetest.register_on_sound_play(function(SimpleSoundSpec))`
+ * Called when recieving a play sound command from server
+ * Newest functions are called first
+ * If any function returns true, the sound does not play
### Setting-related
* `minetest.settings`: Settings object containing all of the settings from the
*pkt >> pitch;
*pkt >> ephemeral;
} catch (PacketError &e) {};
-
+
+ SimpleSoundSpec sound_spec(name, gain, fade, pitch);
+
+ if (m_mods_loaded && m_script->on_play_sound(sound_spec))
+ return;
+
// Start playing
int client_id = -1;
switch(type) {
return readParam<bool>(L, -1);
}
+bool ScriptApiClient::on_play_sound(SimpleSoundSpec spec)
+{
+ SCRIPTAPI_PRECHECKHEADER
+
+ // Get core.registered_on_play_sound
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_play_sound");
+
+ // Push data
+ push_soundspec(L, spec);
+
+ // Call functions
+ runCallbacks(1, RUN_CALLBACKS_MODE_OR);
+ return readParam<bool>(L, -1);
+}
+
bool ScriptApiClient::on_inventory_open(Inventory *inventory)
{
SCRIPTAPI_PRECHECKHEADER
bool on_placenode(const PointedThing &pointed, const ItemDefinition &item);
bool on_item_use(const ItemStack &item, const PointedThing &pointed);
bool on_recieve_physics_override(float override_speed, float override_jump, float override_gravity, bool sneak, bool sneak_glitch, bool new_move);
+ bool on_play_sound(SimpleSoundSpec spec);
bool on_inventory_open(Inventory *inventory);
void open_enderchest();