aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-24 11:10:28 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-24 11:10:28 +0200
commit06e93f8d9508a23e86751dfae2f6a7e550d8e1af (patch)
tree3e3a9a0dc78ee6c216b047304b53bfe1d3d3ce0e /src
parent74780134f2825427bb0db3b370642d3512af5ecd (diff)
downloadminetest-06e93f8d9508a23e86751dfae2f6a7e550d8e1af.tar.gz
minetest-06e93f8d9508a23e86751dfae2f6a7e550d8e1af.tar.bz2
minetest-06e93f8d9508a23e86751dfae2f6a7e550d8e1af.zip
Add sound.dig
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp16
-rw-r--r--src/nodedef.cpp3
-rw-r--r--src/nodedef.h1
-rw-r--r--src/scriptapi.cpp3
4 files changed, 19 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 9715c6676..1dcda043e 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2250,10 +2250,18 @@ void the_game(
params = getDigParams(nodedef->get(n).groups, tp);
}
- if(params.main_group != ""){
- soundmaker.m_player_leftpunch_sound.gain = 0.5;
- soundmaker.m_player_leftpunch_sound.name =
- std::string("default_dig_") + params.main_group;
+ SimpleSoundSpec sound_dig = nodedef->get(n).sound_dig;
+ if(sound_dig.exists()){
+ if(sound_dig.name == "__group"){
+ if(params.main_group != ""){
+ soundmaker.m_player_leftpunch_sound.gain = 0.5;
+ soundmaker.m_player_leftpunch_sound.name =
+ std::string("default_dig_") +
+ params.main_group;
+ }
+ } else{
+ soundmaker.m_player_leftpunch_sound = sound_dig;
+ }
}
float dig_time_complete = 0.0;
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 954467d48..6bdb36261 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -156,6 +156,7 @@ void ContentFeatures::reset()
legacy_facedir_simple = false;
legacy_wallmounted = false;
sound_footstep = SimpleSoundSpec();
+ sound_dig = SimpleSoundSpec("__group");
sound_dug = SimpleSoundSpec();
}
@@ -204,6 +205,7 @@ void ContentFeatures::serialize(std::ostream &os)
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
serializeSimpleSoundSpec(sound_footstep, os);
+ serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os);
}
@@ -258,6 +260,7 @@ void ContentFeatures::deSerialize(std::istream &is)
legacy_wallmounted = readU8(is);
try{
deSerializeSimpleSoundSpec(sound_footstep, is);
+ deSerializeSimpleSoundSpec(sound_dig, is);
deSerializeSimpleSoundSpec(sound_dug, is);
}catch(SerializationError &e) {};
}
diff --git a/src/nodedef.h b/src/nodedef.h
index 585755b9d..a7ffa5a2e 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -203,6 +203,7 @@ struct ContentFeatures
// Sound properties
SimpleSoundSpec sound_footstep;
+ SimpleSoundSpec sound_dig;
SimpleSoundSpec sound_dug;
/*
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index fce760eb8..5ce5f3b29 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -1062,6 +1062,9 @@ static ContentFeatures read_content_features(lua_State *L, int index)
lua_getfield(L, -1, "footstep");
read_soundspec(L, -1, f.sound_footstep);
lua_pop(L, 1);
+ lua_getfield(L, -1, "dig");
+ read_soundspec(L, -1, f.sound_dig);
+ lua_pop(L, 1);
lua_getfield(L, -1, "dug");
read_soundspec(L, -1, f.sound_dug);
lua_pop(L, 1);