12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- sounds = {}
- minetest.register_node('sounds:test', {
- description = 'biome test',
- tiles = {'letters_station.png'},
- paramtype = 'light',
- paramtype2 = 'facedir',
- selection_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, .5, .5}},
- collision_box = {
- type = 'fixed',
- fixed = {-.5, -.5, -.5, .5, .5, .5}},
- groups = {oddly_breakable_by_hand=2, choppy=3, not_in_creative_inventory=1},
- on_punch = function(pos, node, puncher, pointed_thing)
- local player_name = puncher:get_player_name()
- local biome_data = minetest.get_biome_data(pos)
- local biome_id = biome_data.biome
- local biome_name = minetest.get_biome_name(biome_id)
- minetest.chat_send_player(player_name, 'You are in a '..biome_name..' biome.')
- sounds.play_sound(puncher)
- end
- })
- function sounds.random_player()
- local key = #(minetest.get_connected_players())
- local people = minetest.get_connected_players()
- local person = math.random(1, key)
- local name = people[person] --userdata
- sounds.play_sound(name)
- end
- function sounds.play_sound(player)
- if player then
- local pos = player:get_pos()
- if pos.y > -20 and pos.y < 500 then
- local player_name = player:get_player_name()
- local biome_data = minetest.get_biome_data(pos)
- local biome_id = biome_data.biome
- local biome_name = minetest.get_biome_name(biome_id)
- if biome_name == 'grassland_ocean' or biome_name == 'snowy_grassland_ocean'
- or biome_name == 'savanna_ocean' or biome_name == 'taiga_ocean' then
- minetest.sound_play('ocean_beach', {to_player = player_name, gain = .5})
- elseif biome_name == 'rainforest' then
- minetest.sound_play('rainforest', {to_player = player_name, gain = .75})
- elseif biome_name == 'grassland' then
- minetest.sound_play('grassland', {to_player = player_name, gain = .75})
- elseif biome_name == 'deciduous_forest' then
- minetest.sound_play('deciduous_forest', {to_player = player_name, gain = .75})
- elseif biome_name == 'coniferous_forest' then
- minetest.sound_play('coniferous_forest', {to_player = player_name, gain = .75})
- elseif biome_name == 'desert' or biome_name == 'sandstone_desert' then
- minetest.sound_play('desert', {to_player = player_name, gain = .75})
- elseif biome_name == 'icesheet' then
- minetest.sound_play('icesheet', {to_player = player_name, gain = .75})
- elseif biome_name == 'savanna' then
- minetest.sound_play('savanna', {to_player = player_name, gain = .7})
- elseif biome_name == 'tundra' then
- minetest.sound_play('tundra', {to_player = player_name, gain = .7})
- end
- end
- end
- end
|