Add sound.dig
authorPerttu Ahola <celeron55@gmail.com>
Sat, 24 Mar 2012 09:10:28 +0000 (11:10 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 24 Mar 2012 09:10:28 +0000 (11:10 +0200)
games/mesetint/mods/default/init.lua
src/game.cpp
src/nodedef.cpp
src/nodedef.h
src/scriptapi.cpp

index 042cb7cdfb826ba7d99864ead89808bde5af6970..8788b38102963d09ba8e70fbb95a354dd4cc1d55 100644 (file)
@@ -656,8 +656,10 @@ function default.node_sound_sand_defaults(table)
        table = table or {}
        table.footstep = table.footstep or
                        {name="default_grass_footstep", gain=0.25}
+       --table.dug = table.dug or
+       --              {name="default_dirt_break", gain=0.25}
        table.dug = table.dug or
-                       {name="default_dirt_break", gain=0.25}
+                       {name="", gain=0.25}
        default.node_sound_defaults(table)
        return table
 end
@@ -674,6 +676,8 @@ function default.node_sound_leaves_defaults(table)
        table = table or {}
        table.footstep = table.footstep or
                        {name="default_grass_footstep", gain=0.25}
+       table.dig = table.dig or
+                       {name="default_dig_crumbly", gain=0.4}
        table.dug = table.dug or
                        {name="", gain=1.0}
        default.node_sound_defaults(table)
@@ -727,7 +731,7 @@ minetest.register_node("default:dirt_with_grass", {
        groups = {crumbly=3},
        drop = 'default:dirt',
        sounds = default.node_sound_dirt_defaults({
-               footstep = {name="default_grass_footstep", gain=0.5},
+               footstep = {name="default_grass_footstep", gain=0.4},
        }),
 })
 
@@ -738,7 +742,7 @@ minetest.register_node("default:dirt_with_grass_footsteps", {
        groups = {crumbly=3},
        drop = 'default:dirt',
        sounds = default.node_sound_dirt_defaults({
-               footstep = {name="default_grass_footstep", gain=0.5},
+               footstep = {name="default_grass_footstep", gain=0.4},
        }),
 })
 
@@ -763,8 +767,8 @@ minetest.register_node("default:gravel", {
        tile_images = {"default_gravel.png"},
        is_ground_content = true,
        groups = {crumbly=2},
-       sounds = default.node_sound_sand_defaults({
-               footstep = {name="default_gravel_footstep", gain=0.5}
+       sounds = default.node_sound_dirt_defaults({
+               footstep = {name="default_gravel_footstep", gain=0.45},
        }),
 })
 
index 9715c6676545961c9759ebed8858ee051cf5cb7b..1dcda043e763fd57e0e70788f30dac85be8f5f0a 100644 (file)
@@ -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;
index 954467d4874f15fae4021568325f3103a0fd04df..6bdb362610bf9256253abdef7bdfe3e58a622af6 100644 (file)
@@ -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) {};
 }
index 585755b9d89554104d30891f1d7be4c7bb4a49f7..a7ffa5a2ee44073969a7785b018f0783b4e43bd8 100644 (file)
@@ -203,6 +203,7 @@ struct ContentFeatures
 
        // Sound properties
        SimpleSoundSpec sound_footstep;
+       SimpleSoundSpec sound_dig;
        SimpleSoundSpec sound_dug;
 
        /*
index fce760eb8959fd418ca5ea810fccd3bfec66712e..5ce5f3b2953ec969321b461b0026a2c6c836f504 100644 (file)
@@ -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);