Use sounds mod for playing sounds

This commit is contained in:
Jordan Irwin 2021-08-14 21:47:17 -07:00
parent 0098ef5da4
commit 45e59dbf8b
9 changed files with 16 additions and 7 deletions

1
.gitattributes vendored
View file

@ -1,2 +1 @@
.* export-ignore
sounds_src/ export-ignore

View file

@ -10,9 +10,6 @@ A [Minetest][] mod that can be used to remove/replace unknown entities, nodes, &
- Code: [MIT](LICENSE.txt)
- Textures: CC0
- Sounds:
- cleaner_pencil_write: [CC0](https://freesound.org/people/NachtmahrTV/sounds/571800/)
- cleaner_pencil_erase: [CC0](https://freesound.org/people/damsur/sounds/443241/)
### Requirements:

View file

@ -1,4 +1,9 @@
next
----
- use sounds mod for sounds
v1.2
----
- added API

View file

@ -151,6 +151,7 @@ local tool = {
end,
}
local use_sounds = core.global_exists("sounds")
local sound_handle
tool.on_use = function(stack, user, pointed_thing)
@ -175,17 +176,23 @@ tool.on_use = function(stack, user, pointed_thing)
if mode == "erase" then
core.remove_node(npos)
sound_handle = core.sound_play("cleaner_pencil_erase", {object=user})
if use_sounds then
local sound_handle = sounds.pencil_erase({object=user})
end
return stack
elseif core.registered_nodes[new_node_name] then
if mode == "swap" then
core.swap_node(npos, {name=new_node_name})
sound_handle = core.sound_play("cleaner_pencil_write", {object=user})
if use_sounds then
local sound_handle = sounds.pencil_write({object=user})
end
elseif mode == "write" then
local node_above = core.get_node_or_nil(pointed_thing.above)
if not node_above or node_above.name == "air" then
core.set_node(pointed_thing.above, {name=new_node_name})
sound_handle = core.sound_play("cleaner_pencil_write", {object=user})
if use_sounds then
local sound_handle = sounds.pencil_write({object=user})
end
else
core.chat_send_player(pname, S("Can't place node there."))
end

View file

@ -4,3 +4,4 @@ version = 1.2
license = MIT
author = PilzAdam, Jordan Irwin (AntumDeluge)
min_minetest_version = 5.0
optional_depends = sounds

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.