Page 1 of 1

[Question]How to make this?

PostPosted: Mon Oct 12, 2015 18:47
by MineYoshi
How to make when you touch or make an action with a tool, the tool sounds?

Re: [Question]How to make this?

PostPosted: Tue Oct 13, 2015 11:05
by Don
MineYoshi wrote:How to make when you touch or make an action with a tool, the tool sounds?

http://dev.minetest.net/minetest.sound_play

Re: [Question]How to make this?

PostPosted: Wed Oct 14, 2015 13:27
by MineYoshi
explain me ,please.
i Don't understand that wiki article!

Re: [Question]How to make this?

PostPosted: Wed Oct 14, 2015 14:04
by Don
For example if you wanted to make a sound when you destroy a block then add this to your node definition

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
   on_destruct = function(pos)
      minetest.sound_play("your_sound_file", {
         pos = pos,
         max_hear_distance = 100,
         gain = 10.0,
      })
   end,


In your mod folder make a folder called sounds. Put you sound file in there. It has to be an ogg file.
In your code put the name of the sound file where I wrote "your_sound_file". Do not put .ogg.
If your file is called mineyoshi.ogg then you would write "mineyoshi".

Re: [Question]How to make this?

PostPosted: Thu Oct 15, 2015 06:51
by kaeza
I think he means when you use a tool (i.e. by clicking [not necessarily a node] while the tool is in hand).

If that's the case, you should define an `on_use` callback for the tool itself, and call `sound_play` from there..

Re: [Question]How to make this?

PostPosted: Mon Oct 19, 2015 13:46
by MineYoshi
Thanks kaeza ! that was i wanted to say

EDIT: i am making a "Headphones Mod" and that was what i need THANKS!