added initial mods

master
Brett O'Donnell 2012-10-04 17:11:15 +09:30
commit dc6da6ebf4
1277 changed files with 64161 additions and 0 deletions

9
3dforniture/README.txt Normal file
View File

@ -0,0 +1,9 @@
[Mod] 3D Furniture [1.0] [3dforniture]
Homepage: http://minetest.net/forum/viewtopic.php?id=2207
License: GPL
Contributors:
tonyka - author
InfinityProject - suggested creating bathroom kit
cosarara97 - code

104
3dforniture/crafting.lua Normal file
View File

@ -0,0 +1,104 @@
minetest.register_craft( {
output = '3dforniture:table',
recipe = {
{ 'default:wood','default:wood', 'default:wood' },
{ 'default:stick', '', 'default:stick' },
},
})
minetest.register_craft( {
output = '3dforniture:chair 2',
recipe = {
{ 'default:stick',''},
{ 'default:wood','default:wood' },
{ 'default:stick','default:stick' },
},
})
minetest.register_craft( {
output = '3dforniture:bars 10',
recipe = {
{ 'default:steel_ingot','default:steel_ingot','default:steel_ingot' },
{ 'default:steel_ingot','default:steel_ingot','default:steel_ingot' },
},
})
minetest.register_craft( {
output = '3dforniture:L_binding_bars 4',
recipe = {
{ '3dforniture:bars','' },
{ '3dforniture:bars','3dforniture:bars' },
},
})
minetest.register_craft( {
output = '3dforniture:chains 4',
recipe = {
{'','default:steel_ingot',''},
{ 'default:steel_ingot','', 'default:steel_ingot' },
{ '', 'default:steel_ingot', '' },
},
})
minetest.register_craft( {
output = '3dforniture:torch_wall 10',
recipe = {
{ 'default:coal_lump' },
{ 'default:steel_ingot' },
},
})
minetest.register_craft( {
output = '3dforniture:toilet',
recipe = {
{'','','bucket:bucket_water'},
{ 'default:cobble','default:cobble', 'default:cobble' },
{ '', 'bucket:bucket_empty', '' },
},
})
minetest.register_craft( {
output = '3dforniture:sink',
recipe = {
{ 'default:cobble','bucket:bucket_empty', 'default:cobble' },
},
})
minetest.register_craft( {
output = '3dforniture:taps',
recipe = {
{ 'default:steel_ingot','bucket:bucket_water', 'default:steel_ingot' },
},
})
minetest.register_craft( {
output = '3dforniture:shower_tray',
recipe = {
{ 'default:cobble','bucket:bucket_water', 'default:cobble' },
},
})
minetest.register_craft( {
output = '3dforniture:shower_head',
recipe = {
{ 'default:steel_ingot','bucket:bucket_water' },
},
})
--fuel
minetest.register_craft({
type = 'fuel',
recipe = '3dforniture:table',
burntime = 30,
})
minetest.register_craft({
type = 'fuel',
recipe = '3dforniture:chair',
burntime = 15,
})

1
3dforniture/depends.txt Normal file
View File

@ -0,0 +1 @@
default

74
3dforniture/init.lua Normal file
View File

@ -0,0 +1,74 @@
--[[
--Mod: 3D FORNITURE
--V: 1.0
--Autor: Tonyka
--Agradecimientos a: cosarara97, InfinityProject
------------------------
-- Copyright GNU GPL --
------------------------
--]]
dofile(minetest.get_modpath("3dforniture").."/crafting.lua")
dofile(minetest.get_modpath("3dforniture").."/nodes.lua")
--alias
minetest.register_alias('table', '3dforniture:table')
minetest.register_alias('chair', '3dforniture:chair')
minetest.register_alias('bars', '3dforniture:bars')
minetest.register_alias('binding_bars', '3dforniture:L_binding_bars')
minetest.register_alias('chains', '3dforniture:chains')
minetest.register_alias('torch_wall', '3dforniture:torch_wall')
minetest.register_alias('toilet', '3dforniture:toilet')
minetest.register_alias('sink', '3dforniture:sink')
minetest.register_alias('taps', '3dforniture:taps')
minetest.register_alias('shower_tray', '3dforniture:shower_tray')
minetest.register_alias('shower_head', '3dforniture:shower_head')
--[[
minetest.register_abm(
{nodenames = {"3dforniture:toilet"},
interval = 0.02 ,
chance = 1,
action = function(pos)
--pos.y=pos.y
minetest.env:add_node(pos, {name="3dforniture:toilet_open"})
--minetest.env:remove_node(pos, {name="3dforniture:toilet_open"})
end,
})
minetest.register_abm(
{nodenames = {"3dforniture:toilet_open"},
interval = 0.02,
chance = 1,
action = function(pos)
--pos.y=pos.y
minetest.env:add_node(pos, {name="3dforniture:toilet"})
end,
})
]]
--[[
minetest.register_abm(
{nodenames = {"default:tree"},
interval = 1 ,
chance = 1,
action = function(pos)
--pos.y=pos.y
minetest.env:add_node(pos, {name="default:tree"})
--minetest.env:remove_node(pos, {name="3dforniture:toilet_open"})
end,
})
]]
--[[
local on_toilet_puncher = function (pos, node, puncher)
if node.name == '3dforniture:toilet' then
minetest.env:add_node(pos, {name="3dforniture:toilet_open"})
nodeupdate(pos)
elseif node.name == '3dforniture:toilet_open' then
minetest.env:add_node(pos, {name="3dforniture:toilet"})
nodeupdate(pos)
end
end
minetest.register_on_punchnode(on_toilet_puncher)
]]--
----------------------------------------------------------------

454
3dforniture/nodes.lua Normal file
View File

@ -0,0 +1,454 @@
--nodes
minetest.register_node("3dforniture:table", {
description = 'Table',
tiles = {
"forniture_wood.png",
"forniture_wood.png",
"forniture_wood_s1.png",
"forniture_wood_s1.png",
"forniture_wood_s2.png",
"forniture_wood_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.4,-0.5,-0.4, -0.3,0.4,-0.3},
{0.3,-0.5,-0.4, 0.4,0.4,-0.3},
{-0.4,-0.5,0.3, -0.3,0.4,0.4},
{0.3,-0.5,0.3, 0.4,0.4,0.4},
{-0.5,0.4,-0.5, 0.5,0.5,0.5},
{-0.4,-0.2,-0.3, -0.3,-0.1,0.3},
{0.3,-0.2,-0.4, 0.4,-0.1,0.3},
{-0.3,-0.2,-0.4, 0.4,-0.1,-0.3},
{-0.3,-0.2,0.3, 0.3,-0.1,0.4},
},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
})
minetest.register_node("3dforniture:chair", {
description = 'Chair',
tiles = {
"forniture_wood.png",
"forniture_wood.png",
"forniture_wood_s1.png",
"forniture_wood_s1.png",
"forniture_wood_s2.png",
"forniture_wood_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.3,-0.5,0.2, -0.2,0.5,0.3},
{0.2,-0.5,0.2, 0.3,0.5,0.3},
{-0.3,-0.5,-0.3, -0.2,-0.1,-0.2},
{0.2,-0.5,-0.3, 0.3,-0.1,-0.2},
{-0.3,-0.1,-0.3, 0.3,0,0.2},
{-0.2,0.1,0.25, 0.2,0.4,0.26}
},
},
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
})
minetest.register_node("3dforniture:bars", {
description = 'Bars',
tiles = {
"forniture_black_metal.png",
"forniture_black_metal.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s2.png",
"forniture_black_metal_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,-0.1, -0.4,0.5,0.1},
{-0.1,-0.5,-0.1, 0.1,0.5,0.1},
{0.4,-0.5,-0.1, 0.5,0.5,0.1},
{-0.5,-0.5,-0.05, 0.5,-0.45,0.05},
{-0.5,0.45,-0.05, 0.5,0.5,0.05}
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.1, 0.5, 0.5, 0.1},
},
groups = {cracky=1}
})
minetest.register_node("3dforniture:L_binding_bars", {
description = 'Binding Bars',
tiles = {
"forniture_black_metal.png",
"forniture_black_metal.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s2.png",
"forniture_black_metal_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.1,-0.5,-0.5, 0.1,0.5,-0.4},
{-0.15,-0.5,-0.15, 0.15,0.5,0.15},
{0.4,-0.5,-0.1, 0.5,0.5,0.1},
{0,-0.5,-0.05, 0.5,-0.45,0.05},
{-0.05,-0.5,-0.5, 0.05,-0.45,0},
{0,0.45,-0.05, 0.5,0.5,0.05},
{-0.05,0.45,-0.5, 0.05,0.5,0},
},
},
groups = {cracky=1,}
})
minetest.register_node("3dforniture:chains", {
description = 'Chains',
tiles = {
"forniture_black_metal.png",
"forniture_black_metal.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s1.png",
"forniture_black_metal_s2.png",
"forniture_black_metal_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
--chain a
--supporting
{-0.45,0.25,0.45, -0.2,0.5,0.5},
{-0.35,0.4,0.35, -0.3,0.45,0.45},
{-0.35,0.3,0.35, -0.3,0.35,0.45},
{-0.35,0.35,0.3, -0.3,0.4,0.35},
--link 1
{-0.4,0.35,0.35, -0.25,0.4,0.4},
{-0.4,0.15,0.35, -0.25,0.2,0.4},
{-0.45,0.2,0.35, -0.4,0.35,0.4},
{-0.25,0.2,0.35, -0.2,0.35,0.4},
--link 2
{-0.35,0.2,0.3, -0.3,0.25,0.45},
{-0.35,0,0.3, -0.3,0.05,0.45},
{-0.35,0.05,0.25, -0.3,0.2,0.3},
{-0.35,0.05,0.45, -0.3,0.2,0.5},
--link 3
{-0.4,0.05,0.35, -0.25,0.1,0.4},
{-0.4,-0.15,0.35, -0.25,-0.1,0.4},
{-0.45,-0.1,0.35, -0.4,0.05,0.4},
{-0.25,-0.1,0.35, -0.2,0.05,0.4},
--link 4
{-0.35,-0.1,0.3, -0.3,-0.05,0.45},
{-0.35,-0.3,0.3, -0.3,-0.25,0.45},
{-0.35,-0.25,0.25, -0.3,-0.1,0.3},
{-0.35,-0.25,0.45, -0.3,-0.1,0.5},
--link 5
{-0.4,-0.25,0.35, -0.25,-0.2,0.4},
{-0.4,-0.45,0.35, -0.25,-0.4,0.4},
{-0.45,-0.4,0.35, -0.4,-0.25,0.4},
{-0.25,-0.4,0.35, -0.2,-0.25,0.4},
--chain b
--supporting
{0.2,0.25,0.45, 0.45,0.5,0.5},
{0.3,0.4,0.35, 0.35,0.45,0.45},
{0.3,0.3,0.35, 0.35,0.35,0.45},
{0.3,0.35,0.3, 0.35,0.4,0.35},
--link 1
{0.25,0.35,0.35, 0.4,0.4,0.4},
{0.25,0.15,0.35, 0.4,0.2,0.4},
{0.2,0.2,0.35, 0.25,0.35,0.4},
{0.4,0.2,0.35, 0.45,0.35,0.4},
--link 2
{0.3,0.2,0.3, 0.35,0.25,0.45},
{0.3,0,0.3, 0.35,0.05,0.45},
{0.3,0.05,0.25, 0.35,0.2,0.3},
{0.3,0.05,0.45, 0.35,0.2,0.5},
--link 3
{0.25,0.05,0.35, 0.4,0.1,0.4},
{0.25,-0.15,0.35, 0.4,-0.1,0.4},
{0.2,-0.1,0.35, 0.25,0.05,0.4},
{0.4,-0.1,0.35, 0.45,0.05,0.4},
--link 4
{0.3,-0.1,0.3, 0.35,-0.05,0.45},
{0.3,-0.3,0.3, 0.35,-0.25,0.45},
{0.3,-0.25,0.25, 0.35,-0.1,0.3},
{0.3,-0.25,0.45, 0.35,-0.1,0.5},
---link 5
{0.25,-0.25,0.35, 0.4,-0.2,0.4},
{0.25,-0.45,0.35, 0.4,-0.4,0.4},
{0.2,-0.4,0.35, 0.25,-0.25,0.4},
{0.4,-0.4,0.35, 0.45,-0.25,0.4},
},
},
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, 1/4, 1/2, 1/2, 1/2},
},
groups = {cracky=1}
})
minetest.register_node("3dforniture:torch_wall", {
description = "Torch Wall",
drawtype = "nodebox",
tiles = {
"forniture_torch_wall_s.png",
"forniture_torch_wall_i.png",
{name="forniture_torch_wall_anim.png", animation={type="vertical_frames", aspect_w=40, aspect_h=40, length=1.0}}},
paramtype = 'light',
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
--torch
{-0.05,-0.45,0.45, 0.05,-0.35,0.5},
{-0.05,-0.35,0.4, 0.05,-0.25,0.5},
{-0.05,-0.25,0.35, 0.05,-0.15,0.45},
{-0.05,-0.15,0.3, 0.05,-0.05,0.4},
{-0.05,-0.05,0.25, 0.05,0,0.35},
-- fire
{-0.1,0,0.2, 0.1,0.05,0.4},
{-0.15,0.05,0.15, 0.15,0.15,0.45},
{-0.1,0.15,0.2, 0.1,0.25,0.4},
{-0.05,0.25,0.25, 0.05,0.35,0.35},
},
},
sunlight_propagates = true,
walkable = false,
light_source = 18,
selection_box = {
type = "fixed",
fixed = {-0.15, -0.45, 0.15, 0.15, 0.35, 0.5},
},
groups = {cracky=2}
})
minetest.register_node("3dforniture:toilet", {
description = 'Toilet',
tiles = {
"forniture_marble.png",
"forniture_marble.png",
"forniture_marble_s1.png",
"forniture_marble_s1.png",
"forniture_marble_s2.png",
"forniture_marble_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
node_box = {
type = "fixed",
fixed = {
{-0.2,-0.5,-0.2, 0.2,-0.45,0.5},
{-0.1,-0.45,-0.1, 0.1,0,0.5},
{-0.3,-0.2,-0.3, 0.3,0,0.35},
{-0.25,0,-0.25, 0.25,0.05,0.25},
{-0.3,0,0.3, 0.3,0.4,0.5},
{-0.05,0.4,0.35, 0.05,0.45,0.45},
},
},
drop = "3dforniture:toilet",
groups = {cracky=2,}
})
minetest.register_node("3dforniture:toilet_open", {
description = 'Toilet',
tiles = {
"forniture_marble_top_toilet.png",
"forniture_marble.png",
"forniture_marble_sb1.png",
"forniture_marble_sb1.png",
"forniture_marble_sb2.png",
"forniture_marble_sb2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
node_box = {
type = "fixed",
fixed = {
{-0.2,-0.5,-0.2, 0.2,-0.45,0.5},
{-0.1,-0.45,-0.1, 0.1,-0.2,0.5},
{-0.1,-0.2,0.3, 0.1,0,0.5},
{-0.3,-0.2,0.1, 0.3,0,0.35},
{-0.3,-0.2,-0.3, -0.1,-0.15,0.1},
{-0.1,-0.2,-0.3, 0.1,-0.15,-0.1},
{0.1,-0.2,-0.3, 0.3,-0.15,0.1},
{-0.3,-0.15,-0.3, -0.2,0,0.1},
{-0.2,-0.15,-0.3, 0.2,0,-0.2},
{0.2,-0.15,-0.3, 0.3,0,0.1},
{-0.25,0,0.2, 0.25,0.5,0.25},
{-0.3,0,0.3, 0.3,0.4,0.5},
},
},
drop = "3dforniture:toilet",
groups = {cracky=2,}
})
minetest.register_node("3dforniture:sink", {
description = 'Sink',
tiles = {
"forniture_marble_top_sink.png",
"forniture_marble.png",
"forniture_marble_sb1.png",
"forniture_marble_sb1.png",
"forniture_marble_sb2.png",
"forniture_marble_sb2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
node_box = {
type = "fixed",
fixed = {
{-0.15,0.35,0.2, 0.15,0.4,0.5},
{-0.25,0.4,0.4, 0.25,0.45,0.5},
{-0.25,0.4,0.15, -0.15,0.45,0.4},
{0.15,0.4,0.15, 0.25,0.45,0.4},
{-0.15,0.4,0.15, 0.15,0.45,0.2},
{-0.3,0.45,0.4, 0.3,0.5,0.5},
{-0.3,0.45,0.1, -0.25,0.5,0.4},
{0.25,0.45,0.1, 0.3,0.5,0.4},
{-0.25,0.45,0.1, 0.25,0.5,0.15},
},
},
selection_box = {
type = "fixed",
fixed = {-0.3,0.35,0.1, 0.3,0.5,0.5},
},
groups = {cracky=2,}
})
minetest.register_node("3dforniture:taps", {
description = 'Taps',
tiles = {
"forniture_metal.png",
"forniture_metal.png",
"forniture_metal_s1.png",
"forniture_metal_s1.png",
"forniture_metal_s2.png",
"forniture_metal_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
node_box = {
type = "fixed",
fixed = {
--base
{-0.25,-0.45,0.49, 0.25,-0.3,0.5},
{-0.05,-0.4,0.25, 0.05,-0.35,0.5},
{-0.05,-0.425,0.25,0.05,-0.4,0.3},
--taps 1
{-0.2,-0.4,0.45, -0.15,-0.35,0.5},
{-0.2,-0.45,0.4, -0.15,-0.3,0.45},
{-0.25,-0.4,0.4, -0.1,-0.35,0.45},
--taps 2
{0.15,-0.4,0.45, 0.2,-0.35,0.5},
{0.15,-0.45,0.4, 0.2,-0.3,0.45},
{0.1,-0.4,0.4, 0.25,-0.35,0.45},
},
},
selection_box = {
type = "fixed",
fixed = {-0.25,-0.45,0.25, 0.25,-0.3,0.5},
},
groups = {cracky=2,}
})
minetest.register_node("3dforniture:shower_tray", {
description = 'Shower Tray',
tiles = {
"forniture_marble_base_ducha_top.png",
"forniture_marble_base_ducha_top.png",
"forniture_marble_sb1.png",
"forniture_marble_sb1.png",
"forniture_marble_sb2.png",
"forniture_marble_sb2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
node_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,-0.5, 0.5,-0.45,0.5},
{-0.5,-0.45,-0.5, 0.5,-0.4,-0.45},
{-0.5,-0.45,0.45, 0.5,-0.4,0.5},
{-0.5,-0.45,-0.45, -0.45,-0.4,0.45},
{0.45,-0.45,-0.45, 0.5,-0.4,0.45},
},
},
selection_box = {
type = "fixed",
fixed = {-0.5,-0.5,-0.5, 0.5,-0.4,0.5},
},
groups = {cracky=2,}
})
minetest.register_node("3dforniture:shower_head", {
description = 'Shower Head',
tiles = {
"forniture_metal.png",
"forniture_metal.png",
"forniture_metal_s1.png",
"forniture_metal_s1.png",
"forniture_metal_s2.png",
"forniture_metal_s2.png",
},
drawtype = "nodebox",
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = 'facedir',
node_box = {
type = "fixed",
fixed = {
{-0.1,-0.5,0.1, 0.1,-0.4,0.3},
{-0.05,-0.4,0.15, 0.05,-0.3,0.25},
{-0.05,-0.35,0.25, 0.05,-0.3,0.5},
{-0.1,-0.4,0.49, 0.1,-0.25,0.5},
},
},
selection_box = {
type = "fixed",
fixed = {-0.1,-0.5,0.1, 0.1,-0.25,0.5},
},
groups = {cracky=2,}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

83
README.txt Normal file
View File

@ -0,0 +1,83 @@
----------------------------------
Go Play Modpack for Minetest
----------------------------------
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-go_play_modpack
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
----------------------------------
Description
----------------------------------
This modpack has many mods installed for a fun and interesting gaming experience.
Although it works with the default minetest_game, it is recommended to use PilzAdam's latest minetest_game, available at: https://github.com/PilzAdam/minetest_game
To view the items and craft recipies, please visit the Game Wiki: http://cornernote.net/minetest/go_play/wiki
----------------------------------
Installation
----------------------------------
Unzip into minetest/mods/
----------------------------------
Mods Used
----------------------------------
Thank you to all the developers who's mods make up this release.
3dforniture - http://minetest.net/forum/viewtopic.php?id=2207
ambience - http://minetest.net/forum/viewtopic.php?id=2807
bags - http://minetest.net/forum/viewtopic.php?id=3081
bones - http://minetest.net/forum/viewtopic.php?id=2206
builtin_item - http://minetest.net/forum/viewtopic.php?id=3188
carts - http://minetest.net/forum/viewtopic.php?id=2451
chess - http://minetest.net/forum/viewtopic.php?id=2784
clock_face - http://minetest.net/forum/viewtopic.php?id=807
craft_guide - http://minetest.net/forum/viewtopic.php?id=2334
farming - http://minetest.net/forum/viewtopic.php?id=2787
flint_and_steel - http://minetest.net/forum/viewtopic.php?id=1683
flowers - http://minetest.net/forum/viewtopic.php?id=2624
food - http://minetest.net/forum/viewtopic.php?id=2960
gates - http://minetest.net/forum/viewtopic.php?id=2943
growing_trees - http://minetest.net/forum/viewtopic.php?id=978
habitat - http://minetest.net/forum/viewtopic.php?id=2619
hatches - http://minetest.net/forum/viewtopic.php?id=609
homedecor - http://minetest.net/forum/viewtopic.php?id=2041
home_gui - http://minetest.net/forum/viewtopic.php?id=3101
infinite_chest - http://minetest.net/forum/viewtopic.php?id=3053
infinitytools - http://minetest.net/forum/viewtopic.php?id=2535
inventory_plus - http://minetest.net/forum/viewtopic.php?id=3100
item_drop - http://minetest.net/forum/viewtopic.php?id=2656
junglegrass - http://minetest.net/forum/viewtopic.php?id=2307
jungletree - http://minetest.net/forum/viewtopic.php?id=2887
jumping - http://minetest.net/forum/viewtopic.php?id=2957
mesecons - http://minetest.net/forum/viewtopic.php?id=628
moreores - http://minetest.net/forum/viewtopic.php?id=549
particles - http://minetest.net/forum/viewtopic.php?id=3082
pipeworks - http://minetest.net/forum/viewtopic.php?id=2155
plants - http://minetest.net/forum/viewtopic.php?id=2619
scaffolding - http://minetest.net/forum/viewtopic.php?id=3205
secret_passage - http://minetest.net/forum/viewtopic.php?id=667
sim_paint - http://minetest.net/forum/viewtopic.php?id=1279
snow - http://minetest.net/forum/viewtopic.php?id=2290
stairsplus - http://minetest.net/forum/viewtopic.php?id=2092
streets - http://minetest.net/forum/viewtopic.php?id=2984
technic - http://minetest.net/forum/viewtopic.php?id=2538
terrariumblocks - http://minetest.net/forum/viewtopic.php?id=2905
vines - http://minetest.net/forum/viewtopic.php?id=2344
xbar - http://minetest.net/forum/viewtopic.php?id=2215
xfences - http://minetest.net/forum/viewtopic.php?id=2127
xpanes - http://minetest.net/forum/viewtopic.php?id=2117
workbench - http://minetest.net/forum/viewtopic.php?id=3275
worldtime - http://minetest.net/forum/viewtopic.php?id=2205

BIN
ambience/ambience.zip Normal file

Binary file not shown.

View File

@ -0,0 +1,390 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .14
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local played_on_start = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
--[[old
local nodes_in_range = function(pos, search_distance, node_name)
local search_p = {x=0, y=0, z=0}
local nodes_found = 0
for p_x=(pos.x-search_distance), (pos.x+search_distance) do
for p_y=(pos.y-search_distance), (pos.y+search_distance) do
for p_z=(pos.z-search_distance), (pos.z+search_distance) do
local search_n = minetest.env:get_node({x=p_x, y=p_y, z=p_z})
if search_n.name == node_name then
nodes_found = nodes_found + 1
end
end
end
end
return nodes_found
--minetest.chat_send_all("Range: " .. tostring(search_distance) .. " | Found (" .. node_name .. ": " .. nodes_found .. ")")
end --]]
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y+1.0
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
end
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 7, "default:water_flowing")>5 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
end
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -0,0 +1,439 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .16
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local played_on_start = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
--[[old
local nodes_in_range = function(pos, search_distance, node_name)
local search_p = {x=0, y=0, z=0}
local nodes_found = 0
for p_x=(pos.x-search_distance), (pos.x+search_distance) do
for p_y=(pos.y-search_distance), (pos.y+search_distance) do
for p_z=(pos.z-search_distance), (pos.z+search_distance) do
local search_n = minetest.env:get_node({x=p_x, y=p_y, z=p_z})
if search_n.name == node_name then
nodes_found = nodes_found + 1
end
end
end
end
return nodes_found
--minetest.chat_send_all("Range: " .. tostring(search_distance) .. " | Found (" .. node_name .. ": " .. nodes_found .. ")")
end --]]
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y+1.0
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
end
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 7, "default:water_flowing")>5 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
pos.y = pos.y-2
nodename = minetest.env:get_node(pos).name
--minetest.chat_send_all("Found " .. nodename .. pos.y )
if string.find(nodename, "default:sand") and pos.y < 5 then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
end
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -0,0 +1 @@
default

789
ambience/ambience/init.lua Normal file
View File

@ -0,0 +1,789 @@
--------------------------------------------------------------------------------------------------------
--Ambience Configuration for version .31
--Working on:
--removing magic leap when not enough air under feet.
--find out why wind stops while flying
--add an extra node near feet to handle treading water as a special case, and don't have to use node under feet. which gets
--invoked when staning on a ledge near water.
--reduce redundant code (stopplay and add ambience to list)
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local desert_frequency = 20 --coyote
local desert_volume = 1.0
local desert_frequent_frequency = 700 --desertwind
local desert_frequent_volume = 1.0
local swimming_frequent_frequency = 1000 --swimming splashes
local swimming_frequent_volume = 1.0
local water_surface_volume = 1.0 -- sloshing water
local lava_volume = 1.0 --lava
local flowing_water_volume = .4 --waterfall
local splashing_water_volume = 1
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local ambiences
local counter=0--*****************
local SOUNDVOLUME = 1
local MUSICVOLUME = 1
local sound_vol = 1
local last_x_pos = 0
local last_y_pos = 0
local last_z_pos = 0
local node_under_feet
local node_at_upper_body
local node_at_lower_body
local node_3_under_feet
local played_on_start = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local swimming_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="water_swimming_splashing_breath", length=11.5, gain=swimming_frequent_volume},
{name="water_swimming_splashing", length=9, gain=swimming_frequent_volume}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local desert = {
handler = {},
frequency = desert_frequency,
{name="coyote2", length=2.5, gain=desert_volume},
{name="RattleSnake", length=8, gain=desert_volume}
}
local desert_frequent = {
handler = {},
frequency = desert_frequent_frequency,
{name="DesertMonolithMed", length=34.5, gain=desert_frequent_volume}
}
local flying = {
handler = {},
frequency = 1000,
on_start = "crystal_airlines",
on_stop = "nothing_yet",
{name="ComboWind", length=17, gain=1}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6, gain=1},
{name="dolphins_screaming", length=16.5, gain=1}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
--on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10, gain=water_frequent_volume}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local water_surface = {
handler = {},
frequency = 1000,
on_stop = "Splash",
on_start = "Splash",
{name="lake_waves_2_calm", length=9.5, gain=water_surface_volume},
{name="lake_waves_2_variety", length=13.1, gain=water_surface_volume}
}
local splashing_water = {
handler = {},
frequency = 1000,
{name="Splash", length=1.22, gain=splashing_water_volume}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=flowing_water_volume}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=flowing_water_volume}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20, gain=lava_volume}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15, gain=lava_volume}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
is_music=true,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local nodes_in_coords = function(minp, maxp, node_name)
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local atleast_nodes_in_grid = function(pos, search_distance, height, node_name, threshold)
counter = counter +1
-- minetest.chat_send_all("counter: (" .. counter .. ")")
minp = {x=pos.x-search_distance,y=height, z=pos.z+20}
maxp = {x=pos.x+search_distance,y=height, z=pos.z+20}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("z+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = #nodes
minp = {x=pos.x-search_distance,y=height, z=pos.z-20}
maxp = {x=pos.x+search_distance,y=height, z=pos.z-20}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("z-Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
maxp = {x=pos.x+20,y=height, z=pos.z+search_distance}
minp = {x=pos.x+20,y=height, z=pos.z-search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("x+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
maxp = {x=pos.x-20,y=height, z=pos.z+search_distance}
minp = {x=pos.x-20,y=height, z=pos.z-search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("x+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
-- minetest.chat_send_all("Found total(" .. totalnodes .. ")")
if totalnodes >= threshold*2 then
return true
end
return false
end
local get_immediate_nodes = function(pos)
pos.y = pos.y-1
node_under_feet = minetest.env:get_node(pos).name
pos.y = pos.y-3
node_3_under_feet = minetest.env:get_node(pos).name
pos.y = pos.y+3
pos.y = pos.y+2.2
node_at_upper_body = minetest.env:get_node(pos).name
pos.y = pos.y-1.19
node_at_lower_body = minetest.env:get_node(pos).name
pos.y = pos.y+0.99
--minetest.chat_send_all("node_under_feet(" .. nodename .. ")")
end
local get_ambience = function(player)
local player_is_climbing = false
local player_is_descending = false
local player_is_moving_horiz = false
local standing_in_water = false
local pos = player:getpos()
get_immediate_nodes(pos)
if last_x_pos ~=pos.x or last_z_pos ~=pos.z then
player_is_moving_horiz = true
end
if pos.y > last_y_pos+.5 then
player_is_climbing = true
end
if pos.y < last_y_pos-.5 then
player_is_descending = true
end
last_x_pos =pos.x
last_z_pos =pos.z
last_y_pos =pos.y
if string.find(node_at_upper_body, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
elseif node_at_upper_body == "air" then
if string.find(node_at_lower_body, "default:water") or string.find(node_under_feet, "default:water") then
--minetest.chat_send_all("bottom counted as water")
--we found air at upperbody, and water at lower body. Now there are 4 possibilities:
--Key: under feet, moving or not
--swimming w, m swimming
--walking in water nw, m splashing
--treading water w, nm sloshing
--standing in water nw, nm beach trumps, then sloshing
if player_is_moving_horiz then
if string.find(node_under_feet, "default:water") then
if music then
return {swimming_frequent=swimming_frequent, music=music}
else
return {swimming_frequent}
end
else --didn't find water under feet: walking in water
if music then
return {splashing_water=splashing_water, music=music}
else
return {splashing_water}
end
end
else--player is not moving: treading water
if string.find(node_under_feet, "default:water") then
if music then
return {water_surface=water_surface, music=music}
else
return {water_surface}
end
else --didn't find water under feet
standing_in_water = true
end
end
end
end
-- minetest.chat_send_all("----------")
-- if not player_is_moving_horiz then
-- minetest.chat_send_all("not moving horiz")
-- else
-- minetest.chat_send_all("moving horiz")
-- end
-- minetest.chat_send_all("nub:" ..node_at_upper_body)
-- minetest.chat_send_all("nlb:" ..node_at_lower_body)
-- minetest.chat_send_all("nuf:" ..node_under_feet)
-- minetest.chat_send_all("----------")
-- if player_is_moving_horiz then
-- minetest.chat_send_all("playermoving")
-- end
-- if player_is_climbing then
-- minetest.chat_send_all("player Climbing")
-- end
-- minetest.chat_send_all("nub:" ..node_at_upper_body)
-- minetest.chat_send_all("nlb:" ..node_at_lower_body)
-- minetest.chat_send_all("nuf:" ..node_under_feet)
-- minetest.chat_send_all("n3uf:" ..node_3_under_feet)
--
local air_or_ignore = {air=true,ignore=true}
minp = {x=pos.x-3,y=pos.y-4, z=pos.z-3}
maxp = {x=pos.x+3,y=pos.y-1, z=pos.z+3}
local air_under_player = nodes_in_coords(minp, maxp, "air")
local ignore_under_player = nodes_in_coords(minp, maxp, "ignore")
air_plus_ignore_under = air_under_player + ignore_under_player
-- minetest.chat_send_all("airUnder:" ..air_under_player)
-- minetest.chat_send_all("ignoreUnder:" ..ignore_under_player)
-- minetest.chat_send_all("a+i:" ..air_plus_ignore_under)
-- minetest.chat_send_all("counter: (" .. counter .. "-----------------)")
--minetest.chat_send_all(air_or_ignore[node_under_feet])
if (player_is_moving_horiz or player_is_climbing) and air_or_ignore[node_at_upper_body] and air_or_ignore[node_at_lower_body]
and air_or_ignore[node_under_feet] and air_plus_ignore_under == 196 and not player_is_descending then
--minetest.chat_send_all("flying!!!!")
if music then
return {flying=flying, music=music}
else
return {flying}
end
end
--minetest.chat_send_all("not flying!!!!")
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 6, "default:water_flowing")>45 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
--if we are near sea level and there is lots of water around the area
if pos.y < 7 and pos.y >0 and atleast_nodes_in_grid(pos, 60, 1, "default:water_source", 51 ) then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if standing_in_water then
if music then
return {water_surface=water_surface, music=music}
else
return {water_surface}
end
end
desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
--minetest.chat_send_all("desertcount: " .. desert_in_range .. ",".. pos.y )
if desert_in_range >250 then
if music then
return {desert=desert, desert_frequent=desert_frequent, music=music}
else
return {desert=desert, desert_frequent=desert_frequent}
end
end
-- pos.y = pos.y-2
-- nodename = minetest.env:get_node(pos).name
-- minetest.chat_send_all("Found " .. nodename .. pos.y )
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number, is_music)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
if is_music then
gain = list[number].gain*MUSICVOLUME
--minetest.chat_send_all("gain music: " .. gain )
else
gain = list[number].gain*SOUNDVOLUME
--minetest.chat_send_all("gain sound: " .. gain )
end
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.swimming_frequent == nil then
local list = swimming_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.desert == nil then
local list = desert
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.desert_frequent == nil then
local list = desert_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_surface == nil then
local list = water_surface
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
-- minetest.chat_send_all("list.on_stop " .. list.on_stop )
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flying == nil then
--minetest.chat_send_all("begin stop flying " )
local list = flying
if list.handler[player_name] ~= nil then
-- minetest.chat_send_all("handler flying " )
if list.on_stop ~= nil then
-- minetest.chat_send_all("onstop flying" )
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.splashing_water == nil then
local list = splashing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
-- if(played_on_start) then
-- -- minetest.chat_send_all("playedOnStart " )
-- else
-- -- minetest.chat_send_all("FALSEplayedOnStart " )
-- end
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name(),gain=SOUNDVOLUME})
end
-- minetest.chat_send_all("ambience: " ..ambience )
-- if ambience.on_start ~= nil and played_on_start_flying == false then
-- played_on_start_flying = true
-- minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
-- end
local is_music =false
if ambience.is_music ~= nil then
is_music = true
end
play_sound(player, ambience, math.random(1, #ambience),is_music)
end
end
end
end)
minetest.register_chatcommand("svol", {
params = "<svol>",
description = "set volume of sounds, default 1 normal volume.",
privs = {server=true},
func = function(name, param)
SOUNDVOLUME = param
-- local player = minetest.env:get_player_by_name(name)
-- ambiences = get_ambience(player)
-- stop_sound({}, player)
minetest.chat_send_player(name, "Sound volume set.")
end, })
minetest.register_chatcommand("mvol", {
params = "<mvol>",
description = "set volume of music, default 1 normal volume.",
privs = {server=true},
func = function(name, param)
MUSICVOLUME = param
-- local player = minetest.env:get_player_by_name(name)
-- stop_sound({}, player)
-- ambiences = get_ambience(player)
minetest.chat_send_player(name, "Music volume set.")
end, })

View File

@ -0,0 +1,287 @@
local night = {
handler = {},
frequency = 10,
{name="horned_owl", length=3},
{name="Wolves_Howling", length=11},
{name="ComboWind", length=17},
}
local night_frequent = {
handler = {},
frequency = 25,
{name="Crickets_At_NightCombo", length=69},
}
local day = {
handler = {},
frequency = 5,
{name="Best Cardinal Bird", length=4},
{name="craw", length=3},
{name="bluejay", length=18},
{name="ComboWind", length=17},
}
local day_frequent = {
handler = {},
frequency = 25,
{name="robin2", length=16},
{name="birdsongnl", length=12.5},
{name="bird", length=30},
}
local cave = {
handler = {},
frequency = 5,
{name="Bats_in_Cave", length=5},
}
local cave_frequent = {
handler = {},
frequency = 100,
{name="drippingwater_drip_a", length=2},
{name="drippingwater_drip_b", length=2},
{name="drippingwater_drip_c", length=2},
{name="Single_Water_Droplet", length=3},
{name="Spooky_Water_Drops", length=7},
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5},
}
local water_frequent = {
handler = {},
frequency = 100,
on_stop = "drowning_gasp",
{name="scuba1bubbles", length=11},
{name="scuba1calm", length=10},
{name="scuba1calm2", length=8.5},
{name="scuba1interestingbubbles", length=11},
{name="scuba1tubulentbubbles", length=10.5},
}
local splash = {
handler = {},
frequency = 100,
{name="Splash", length=1.5},
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = 1,
{name="mtest", length=4*60+33, gain=0.3},
{name="music_1", length=1*60+52, gain=0.3},
{name="ambiance", length=19, gain=0.3},
{name="dark_ambiance", length=46, gain=0.3},
{name="eastern_feeling", length=3*60+51, gain=0.3},
{name="echos", length=2*60+26, gain=0.3},
{name="FoamOfTheSea", length=1*60+50, gain=0.3},
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
local get_ambience = function(player)
local table = {}
local play_water = false
local play_splash = false
local play_day = false
local play_cave = false
local play_night = false
local pos = player:getpos()
pos.y = pos.y+1.5
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
play_water = true
elseif nodename == "air" then
pos.y = pos.y-1.5
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
play_splash = true
end
end
if player:getpos().y < 0 then
play_cave = true
elseif is_daytime() then
play_day = true
else
play_night = true
end
if play_music then
table.music = music
end
if play_water then
table.water = water
table.water_frequent = water_frequent
return table
end
if play_splash then
table.splash = splash
end
if play_day then
table.day = day
table.day_frequent = day_frequent
elseif play_night then
table.night = night
table.night_frequent = night_frequent
elseif play_cave then
table.cave = cave
table.cave_frequent = cave_frequent
end
return table
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.splash == nil then
local list = splash
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 100) <= ambience.frequency then
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -0,0 +1,439 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .16
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local played_on_start = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
--[[old
local nodes_in_range = function(pos, search_distance, node_name)
local search_p = {x=0, y=0, z=0}
local nodes_found = 0
for p_x=(pos.x-search_distance), (pos.x+search_distance) do
for p_y=(pos.y-search_distance), (pos.y+search_distance) do
for p_z=(pos.z-search_distance), (pos.z+search_distance) do
local search_n = minetest.env:get_node({x=p_x, y=p_y, z=p_z})
if search_n.name == node_name then
nodes_found = nodes_found + 1
end
end
end
end
return nodes_found
--minetest.chat_send_all("Range: " .. tostring(search_distance) .. " | Found (" .. node_name .. ": " .. nodes_found .. ")")
end --]]
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y+1.0
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
end
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 7, "default:water_flowing")>5 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
pos.y = pos.y-2
nodename = minetest.env:get_node(pos).name
--minetest.chat_send_all("Found " .. nodename .. pos.y )
if string.find(nodename, "default:sand") and pos.y < 5 then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
end
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -0,0 +1,474 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .17
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local music_frequency = 0 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local played_on_start = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local water_surface = {
handler = {},
frequency = 10,
on_start = "Splash",
{name="lake_waves_2_calm", length=9.5},
{name="lake_waves_2_variety", length=13.1}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
--[[old
local nodes_in_range = function(pos, search_distance, node_name)
local search_p = {x=0, y=0, z=0}
local nodes_found = 0
for p_x=(pos.x-search_distance), (pos.x+search_distance) do
for p_y=(pos.y-search_distance), (pos.y+search_distance) do
for p_z=(pos.z-search_distance), (pos.z+search_distance) do
local search_n = minetest.env:get_node({x=p_x, y=p_y, z=p_z})
if search_n.name == node_name then
nodes_found = nodes_found + 1
end
end
end
end
return nodes_found
--minetest.chat_send_all("Range: " .. tostring(search_distance) .. " | Found (" .. node_name .. ": " .. nodes_found .. ")")
end --]]
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y+1.0
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
elseif nodename == "air" then
pos.y = pos.y-1.5
local nodename = minetest.env:get_node(pos).name
pos.y = pos.y+1.5
if string.find(nodename, "default:water") then
if music then
return {water_surface=water_surface, music=music}
else
return {water_surface}
end
end
end
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 7, "default:water_flowing")>5 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
pos.y = pos.y-2
nodename = minetest.env:get_node(pos).name
--minetest.chat_send_all("Found " .. nodename .. pos.y )
if string.find(nodename, "default:sand") and pos.y < 5 then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_surface == nil then
local list = water_surface
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
minetest.chat_send_all("list.on_stop " .. list.on_stop )
-- played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
end
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -0,0 +1,722 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .29
--working on Flying
--PROB: wind stops short even though it says we are still flying and don't hear the start sound.
--really BIG prob, it ruins water meaning you hear beach while treading water. (find out if still hear it in .28) because
--it is fairly rare in .29
--need a separate onstart variable for flying
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
--for frequencies below use a number between 0 and max_frequency_all
--for volumes below, use a number between 0.0 and 1, the larger the number the louder the sounds
local night_frequency = 20 --owls, wolves
local night_volume = 0.9
local night_frequent_frequency = 150 --crickets
local night_frequent_volume = 0.9
local day_frequency = 100 --crow, bluejay, cardinal
local day_volume = 0.9
local day_frequent_frequency = 1000 --crow, bluejay, cardinal
local day_frequent_volume = 0.18
local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local desert_frequency = 20 --coyote
local desert_volume = 1.0
local desert_frequent_frequency = 700 --desertwind
local desert_frequent_volume = 1.0
local swimming_frequent_frequency = 1000 --swimming splashes
local swimming_frequent_volume = 1.0
local music_frequency = 0 --music (suggestion: keep this one low like around 6)
local music_volume = 0.3
--End of Config
----------------------------------------------------------------------------------------------------
local counter=0--*****************
local last_x_pos = 0
local last_y_pos = 0
local last_z_pos = 0
local node_under_feet
local node_at_upper_body
local node_at_lower_body
local node_3_under_feet
local played_on_start = false
local played_on_start_flying = false
local night = {
handler = {},
frequency = night_frequency,
{name="horned_owl", length=3, gain=night_volume},
{name="Wolves_Howling", length=11, gain=night_volume},
{name="ComboWind", length=17, gain=night_volume}
}
local night_frequent = {
handler = {},
frequency = night_frequent_frequency,
{name="Crickets_At_NightCombo", length=69, gain=night_frequent_volume}
}
local day = {
handler = {},
frequency = day_frequency,
{name="Best Cardinal Bird", length=4, gain=day_volume},
{name="craw", length=3, gain=day_volume},
{name="bluejay", length=18, gain=day_volume},
{name="ComboWind", length=17, gain=day_volume}
}
local day_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="robin2", length=16, gain=day_frequent_volume},
{name="birdsongnl", length=13, gain=day_frequent_volume},
{name="bird", length=30, gain=day_frequent_volume},
{name="Best Cardinal Bird", length=4, gain=day_frequent_volume},
{name="craw", length=3, gain=day_frequent_volume},
{name="bluejay", length=18, gain=day_frequent_volume},
{name="ComboWind", length=17, gain=day_frequent_volume*3}
}
local swimming_frequent = {
handler = {},
frequency = day_frequent_frequency,
{name="water_swimming_splashing_breath", length=11.5, gain=swimming_frequent_volume},
{name="water_swimming_splashing", length=9, gain=swimming_frequent_volume}
}
local cave = {
handler = {},
frequency = cave_frequency,
{name="Bats_in_Cave", length=5, gain=cave_volume}
}
local cave_frequent = {
handler = {},
frequency = cave_frequent_frequency,
{name="drippingwater_drip_a", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_b", length=2, gain=cave_frequent_volume},
{name="drippingwater_drip_c", length=2, gain=cave_frequent_volume},
{name="Single_Water_Droplet", length=3, gain=cave_frequent_volume},
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local desert = {
handler = {},
frequency = desert_frequency,
{name="coyote2", length=2.5, gain=desert_volume},
{name="RattleSnake", length=8, gain=desert_volume}
}
local desert_frequent = {
handler = {},
frequency = desert_frequent_frequency,
{name="DesertMonolithMed", length=34.5, gain=desert_frequent_volume}
}
local flying = {
handler = {},
frequency = 1000,
on_start = "crystal_airlines",
on_stop = "nothing_yet",
{name="ComboWind", length=17, gain=1}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5}
}
local water_frequent = {
handler = {},
frequency = water_frequent_frequency,
on_stop = "drowning_gasp",
--on_start = "Splash",
{name="scuba1bubbles", length=11, gain=water_frequent_volume},
{name="scuba1calm", length=10}, --not sure why but sometimes I get errors when setting gain=water_frequent_volume here.
{name="scuba1calm2", length=8.5, gain=water_frequent_volume},
{name="scuba1interestingbubbles", length=11, gain=water_frequent_volume},
{name="scuba1tubulentbubbles", length=10.5, gain=water_frequent_volume}
}
local water_surface = {
handler = {},
frequency = 1000,
on_stop = "Splash",
on_start = "Splash",
{name="lake_waves_2_calm", length=9.5},
{name="lake_waves_2_variety", length=13.1}
}
local splashing_water = {
handler = {},
frequency = 1000,
{name="Splash", length=1.22, gain=1}
}
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = music_frequency,
{name="mtest", length=4*60+33, gain=music_volume},
{name="echos", length=2*60+26, gain=music_volume},
{name="FoamOfTheSea", length=1*60+50, gain=music_volume},
{name="eastern_feeling", length=3*60+51, gain=music_volume},
{name="Mass_Effect_Uncharted_Worlds", length=2*60+29, gain=music_volume},
{name="dark_ambiance", length=44, gain=music_volume}
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local nodes_in_coords = function(minp, maxp, node_name)
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
--minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local atleast_nodes_in_grid = function(pos, search_distance, height, node_name, threshold)
-- counter = counter +1
-- minetest.chat_send_all("counter: (" .. counter .. ")")
minp = {x=pos.x-search_distance,y=height, z=pos.z+20}
maxp = {x=pos.x+search_distance,y=height, z=pos.z+20}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("z+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = #nodes
minp = {x=pos.x-search_distance,y=height, z=pos.z-20}
maxp = {x=pos.x+search_distance,y=height, z=pos.z-20}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("z-Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
maxp = {x=pos.x+20,y=height, z=pos.z+search_distance}
minp = {x=pos.x+20,y=height, z=pos.z-search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("x+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
maxp = {x=pos.x-20,y=height, z=pos.z+search_distance}
minp = {x=pos.x-20,y=height, z=pos.z-search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("x+Found (" .. node_name .. ": " .. #nodes .. ")")
if #nodes >= threshold then
return true
end
totalnodes = totalnodes + #nodes
-- minetest.chat_send_all("Found total(" .. totalnodes .. ")")
if totalnodes >= threshold*2 then
return true
end
return false
end
local get_immediate_nodes = function(pos)
pos.y = pos.y-1
node_under_feet = minetest.env:get_node(pos).name
pos.y = pos.y-3
node_3_under_feet = minetest.env:get_node(pos).name
pos.y = pos.y+3
pos.y = pos.y+2.2
node_at_upper_body = minetest.env:get_node(pos).name
pos.y = pos.y-1.19
node_at_lower_body = minetest.env:get_node(pos).name
pos.y = pos.y+0.99 --1.6
--minetest.chat_send_all("node_under_feet(" .. nodename .. ")")
end
local get_ambience = function(player)
local player_is_climbing = false
local player_is_descending = false
local player_is_moving_horiz = false
local standing_in_water = false
local pos = player:getpos()
get_immediate_nodes(pos)
if last_x_pos ~=pos.x or last_z_pos ~=pos.z then
player_is_moving_horiz = true
end
if pos.y > last_y_pos+.5 then
player_is_climbing = true
end
if pos.y < last_y_pos-.5 then
player_is_descending = true
end
last_x_pos =pos.x
last_z_pos =pos.z
last_y_pos =pos.y
if string.find(node_at_upper_body, "default:water") then
if music then
return {water=water, water_frequent=water_frequent, music=music}
else
return {water=water, water_frequent=water_frequent}
end
elseif node_at_upper_body == "air" then
if string.find(node_at_lower_body, "default:water") then
--minetest.chat_send_all("bottom counted as water")
--we found air at upperbody, and water at lower body. Now there are 4 possibilities:
--Key: under feet, moving or not
--swimming w, m swimming
--walking in water nw, m splashing
--treading water w, nm sloshing
--standing in water nw, nm beach trumps, then sloshing
if player_is_moving_horiz then
if string.find(node_under_feet, "default:water") then
if music then
return {swimming_frequent=swimming_frequent, music=music}
else
return {swimming_frequent}
end
else --didn't find water under feet: walking in water
if music then
return {splashing_water=splashing_water, music=music}
else
return {splashing_water}
end
end
else--player is not moving
if string.find(node_under_feet, "default:water") then
if music then
return {water_surface=water_surface, music=music}
else
return {water_surface}
end
else --didn't find water under feet
standing_in_water = true
end
end
end
end
if player_is_moving_horiz then
minetest.chat_send_all("playermoving")
end
if player_is_climbing then
minetest.chat_send_all("player Climbing")
end
minetest.chat_send_all("nub:" ..node_at_upper_body)
minetest.chat_send_all("nlb:" ..node_at_lower_body)
minetest.chat_send_all("nuf:" ..node_under_feet)
minetest.chat_send_all("n3uf:" ..node_3_under_feet)
local air_or_ignore = {air=true,ignore=true}
--minetest.chat_send_all(air_or_ignore[node_under_feet])
if (player_is_moving_horiz or player_is_climbing) and air_or_ignore[node_at_upper_body] and air_or_ignore[node_at_lower_body]
and air_or_ignore[node_under_feet] and air_or_ignore[node_3_under_feet] and not player_is_descending then
minetest.chat_send_all("flying!!!!")
if music then
return {flying=flying, music=music}
else
return {flying}
end
end
minetest.chat_send_all("not flying!!!!")
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {lava=lava, lava2=lava2, music=music}
else
return {lava=lava}
end
end
if nodes_in_range(pos, 6, "default:water_flowing")>45 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
--if we are near sea level and there is lots of water around the area
if pos.y < 7 and pos.y >0 and atleast_nodes_in_grid(pos, 60, 1, "default:water_source", 51 ) then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if standing_in_water then
if music then
return {water_surface=water_surface, music=music}
else
return {water_surface}
end
end
desert_in_range = (nodes_in_range(pos, 6, "default:desert_sand")+nodes_in_range(pos, 6, "default:desert_stone"))
--minetest.chat_send_all("desertcount: " .. desert_in_range .. ",".. pos.y )
if desert_in_range >250 then
if music then
return {desert=desert, desert_frequent=desert_frequent, music=music}
else
return {desert=desert, desert_frequent=desert_frequent}
end
end
pos.y = pos.y-2
nodename = minetest.env:get_node(pos).name
-- minetest.chat_send_all("Found " .. nodename .. pos.y )
if player:getpos().y < 0 then
if music then
return {cave=cave, cave_frequent=cave_frequent, music=music}
else
return {cave=cave, cave_frequent=cave_frequent}
end
end
if is_daytime() then
if music then
return {day=day, day_frequent=day_frequent, music=music}
else
return {day=day, day_frequent=day_frequent}
end
else
if music then
return {night=night, night_frequent=night_frequent, music=music}
else
return {night=night, night_frequent=night_frequent}
end
end
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.swimming_frequent == nil then
local list = swimming_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.desert == nil then
local list = desert
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.desert_frequent == nil then
local list = desert_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water == nil then
local list = flowing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_surface == nil then
local list = water_surface
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
-- minetest.chat_send_all("list.on_stop " .. list.on_stop )
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.flying == nil then
--minetest.chat_send_all("begin stop flying " )
local list = flying
if list.handler[player_name] ~= nil then
-- minetest.chat_send_all("handler flying " )
if list.on_stop ~= nil then
-- minetest.chat_send_all("onstop flying" )
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
played_on_start = false
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.splashing_water == nil then
local list = splashing_water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 1000) <= ambience.frequency then
if(played_on_start) then
-- minetest.chat_send_all("playedOnStart " )
else
-- minetest.chat_send_all("FALSEplayedOnStart " )
end
if ambience.on_start ~= nil and played_on_start == false then
played_on_start = true
minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
end
minetest.chat_send_all("ambience: " ..ambience )
-- if ambience.on_start ~= nil and played_on_start_flying == false then
-- played_on_start_flying = true
-- minetest.sound_play(ambience.on_start, {to_player=player:get_player_name()})
-- end
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,103 @@
--------------Music Lic:
Jordach:
--mtest
--dark_ambiance
--eastern_feeling
These sounds are used for the Mod for Minetest; Ambiance.
The included sounds are http://creativecommons.org/licenses/by-nc-sa/3.0/
313hummer (Jordan Craige)
--FoamOfTheSea http://soundcloud.com/jordan-craige/foam-of-the-sea
--echos http://soundcloud.com/jordan-craige/echos-1
Creative Commons Attribution license (reuse allowed) Attribution 3.0 Unported (CC BY 3.0)
xi-intersection:
http://soundcloud.com/xi-intersection/mass-effect-uncharted-worlds Creative Commons License
--not used:
http://soundcloud.com/xi-intersection/donkey-kong-country-2-flight
http://soundcloud.com/kogyo/kogyo-skalar-m1
-----------Sound Lic:
--Nightime Sound, Recorded by Mike Koenig, License: Attribution 3.0 http://soundbible.com/951-Nightime.html
--Crickets At Night Sound, License: Attribution 3.0 | Recorded by Mike Koenig |http://soundbible.com/365-Crickets-At-Night.html
--Medium Pack Of Wolves Howling, License: Public Domain | Recorded by fws.gov, http://soundbible.com/277-Medium-Pack-Of-Wolves-Howling.html
--Horned Owl Sound, License: Attribution 3.0 | Recorded by Mike Koenig , http://soundbible.com/1851-Horned-Owl.html
--Bats In Cave Sound, License: Attr-Noncommercial 3.0 | Recorded by Mike Koenig , http://soundbible.com/1939-Bats-In-Cave.html
--Spooky Water Drops Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/380-Spooky-Water-Drops.html
-- Single Water Droplet Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/384-Single-Water-Droplet.html
--HollowWind, Black Boe, Creative Commons 0 License, http://www.freesound.org/people/Black%20Boe/sounds/22331/
--drippingwater*.ogg sounds: CC0, Dripping Water Mod, by kddekadenz, http://minetest.net/forum/viewtopic.php?id=1688
--best cardinal bird: License: Attribution 3.0 | Recorded by PsychoBird, http://soundbible.com/1515-Best-Cardinal-Bird.html
--birdsongnl: the Attribution License, HerbertBoland, http://www.freesound.org/people/HerbertBoland/sounds/28312/ (end)
--robin2: Attribution License, reinsamba, http://www.freesound.org/people/reinsamba/sounds/32479/ (end)
--Craw.WAV, Attribution License, inchadney, http://www.freesound.org/people/inchadney/sounds/52450/
--bluejay.wav, Creative Commons 0 License, UncleSigmund, http://www.freesound.org/people/UncleSigmund/sounds/42382/
--scuba1*.ogg- digifishmusic, Attribution License, http://www.freesound.org/people/digifishmusic/sounds/45521/
--Underwater Pool - Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/1660-Underwater-Pool.html
--dolphin_screaming - Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/161691/
--dolphins - Attribution Noncommercial License, acclivity, http://www.freesound.org/people/acclivity/sounds/13691/
ComboWind uses:
--wind-in-the-trees -Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/16995/
--drygrassInWind- Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/146436/
--Splash: Attribution 3.0 | Recorded by BlastwaveFx.com, http://soundbible.com/546-Fish-Splashing.html
--small_waterfall Attribution License, volivieri, http://www.freesound.org/people/volivieri/sounds/38390/
--Lake_Waves_2*, Attribution License, Benboncan, http://www.freesound.org/people/Benboncan/sounds/67884/
--water_swimming_splashing*, Attribution Noncommercial License, Robinhood76, http://www.freesound.org/people/Robinhood76/sounds/79657/
--earth01a, Creative Commons 0 License., Halion , http://www.freesound.org/people/Halion/sounds/17785
--fiji_beach, Creative Commons 0 License, c97059890, http://www.freesound.org/people/c97059890/sounds/21754/
--seagull, Attribution Noncommercial License., hazure, http://www.freesound.org/people/hazure/sounds/23707/,
desert:
coyote2, Attribution License, rogerforeman, http://www.freesound.org/people/rogerforeman/sounds/68068/
http://www.freesound.org/people/Proxima4/sounds/104319/
Desert Monolith.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104319/
Rattlesnake Rattle, Public Domain, fws.gov, http://soundbible.com/237-Rattlesnake-Rattle.html
flying:
crystal_airlines: Attribution License, suonho, http://www.freesound.org/people/suonho/sounds/56364/
----------------Not used yet:
desert:
Desert Simple.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104320/
lava:
http://www.freesound.org/people/Halion/sounds/17785/ (almost as good cc) (combine with rocks falling?)
http://www.freesound.org/people/pushtobreak/sounds/17823/ (attrib non cc really good)
http://www.freesound.org/people/klankbeeld/sounds/123970/ (horror rhythm)
Rockfall in mine.wav http://www.freesound.org/people/Benboncan/sounds/60085/
http://www.freesound.org/people/snotch/sounds/96175/ (mud volcano)
--natural night sounds in Boquete.wav, Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/15851/
http://www.freesound.org/people/Dynamicell/sounds/17553/
http://www.freesound.org/people/juskiddink/sounds/78955/ aspen tree in wind
http://www.freesound.org/people/Benboncan/sounds/69761/ wind in hedge birds animals

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
To Do:
-add random_volume parameter to night normal, day normal, & cave normal sounds to create feeling of distance.
m-get constant birds more quiet during the day
m-bats seem way too frequent now?
m-when playing multiplayer seems to increase frequency of music & normal sounds to the point where they are obnoxious
m-which songs should go with which environments? Dark songs in caves or night, light sounds during day.
m-may be drowning out some of the normal sound effects like walking on stone.
l-what about other weird bubble
l-put in wind/ wind in trees during day and night

BIN
ambience/ambience26.zip Normal file

Binary file not shown.

18
ambience/us.stackdump Normal file
View File

@ -0,0 +1,18 @@
MSYS-1.0.12 Build:2011-07-20 17:52
Exception: STATUS_ACCESS_VIOLATION at eip=68085E34
eax=68560000 ebx=00006D34 ecx=00001B4D edx=00000000 esi=00000000 edi=68560000
ebp=0022FE48 esp=0022FE3C program=us
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022FE48 68085E34 (68560000, 00000000, 00006D34, 00000004)
0022FE98 68001CB0 (005D2C52, 00000001, 0022FEE8, 680044EA)
0022FEE8 680045C7 (00000000, 00000000, 0022FF28, 00405894)
0022FF08 68004C5F (00401BB0, 00000000, 00000000, 00000000)
0022FF28 68004C98 (00000000, 00000000, 00000000, 00000000)
0022FF58 004057A4 (00401BB0, 00000000, 00000000, 00000000)
0022FF88 0040103D (7FFDC000, 0022FFD4, 776BE4B6, 7FFDC000)
0022FF94 772D4911 (7FFDC000, F7651B21, 00000000, 00000000)
0022FFD4 776BE4B6 (00401000, 7FFDC000, 00000000, 00000000)
0022FFEC 776BE489 (00401000, 7FFDC000, 00000000, 78746341)
End of stack trace

85
bags/README.txt Normal file
View File

@ -0,0 +1,85 @@
----------------------------------
Bags for Minetest
----------------------------------
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-bags
License: GPLv3
Textures by: tonyka
Texture License: GPLv3
----------------------------------
Description
----------------------------------
Allows players to craft and attach bags to their inventory to increase player item storage capacity.
----------------------------------
Crafts
----------------------------------
8-slot bag:
-S- <- bag:small
WWW S = default:stick
WWW W = default:wood
16-slot bag:
-S- <- bag:medium
BBB S = default:stick
BBB B = bags:small
24-slot bag:
-S- <- bag:large
BBB S = default:stick
BBB B = bags:medium
----------------------------------
Modders Guide
----------------------------------
To turn your craftitem into a bag simply add bagslots=X to the groups in the node definition.
EG:
minetest.register_node("your_mod:your_item", {
description = "Your Item",
groups = {bagslots=16},
})
----------------------------------
License
----------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
----------------------------------
Credits
----------------------------------
Thank you to the minetest community who has shared their code and knowledge with me.

294
bags/api.lua Normal file
View File

@ -0,0 +1,294 @@
--[[
Bags for Minetest
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-particles
License: GPLv3
API
]]--
-- expose api
bags = {}
-- get_formspec
bags.get_formspec = function(player,page)
local formspec = "size[8,8.5]"
.."list[current_player;main;0,3.5;8,4;]"
-- bags
if page=="bags" then
return formspec
.."button[0,7.8;2,0.5;main;Main]"
.."button[0,2;2,0.5;bag1;Bag 1]"
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
.."button[2,2;2,0.5;bag2;Bag 2]"
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
.."button[4,2;2,0.5;bag3;Bag 3]"
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
.."button[6,2;2,0.5;bag4;Bag 4]"
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
end
-- bag
for i=1,4 do
if page=="bag"..i then
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
return formspec
.."button[0,7.8;2,0.5;main;Main]"
.."button[2,7.8;2,0.5;bags;Bags]"
.."image[0,0;1,1;"..image.."]"
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
end
end
-- creative button
if minetest.setting_getbool("creative_mode") then
formspec = formspec .. "button[6,7.8;2,0.5;creative_prev;Creative]"
end
-- default (craft/armor)
return formspec
.."button[0,7.8;2,0.5;bags;Bags]"
.."list[detached:"..player:get_player_name().."_armor;armor_helmet;0,0;1,1;]"
.."list[detached:"..player:get_player_name().."_armor;armor_chest;0,1;1,1;]"
.."list[detached:"..player:get_player_name().."_armor;armor_boots;0,2;1,1;]"
.."list[detached:"..player:get_player_name().."_armor;armor_shield;2,1;1,1;]"
.."image[1,0.5;1,2;player.png]"
.."list[current_player;craft;4,0;3,3;]"
.."list[current_player;craftpreview;7,1;1,1;]"
end
-- on_player_receive_fields
bags.on_player_receive_fields = function(player, formname, fields)
local page = "main"
if fields.creative_prev or fields.creative_next then
page = nil
minetest.after(0.1,function()
player:set_inventory_formspec(player:get_inventory_formspec().."button[5,0;2,0.5;main;Back]")
end)
end
if fields.armor then
page = "armor"
end
if fields.bags then
page = "bags"
end
for i=1,4 do
local bag = "bag"..i
if fields[bag] then
page = "bags"
if bags.get_bagslots(player:get_inventory():get_stack(bag, 1))~=nil then
page = bag
end
end
end
if page~=nil then
if minetest.setting_getbool("creative_mode") then
minetest.after(0.1,function()
player:set_inventory_formspec(bags.get_formspec(player,page))
end)
else
player:set_inventory_formspec(bags.get_formspec(player,page))
end
end
end
-- on_joinplayer
bags.on_joinplayer = function(player)
-- player inventory
local player_inv = player:get_inventory()
-- bags inventory
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
player:get_inventory():set_size(listname.."contents", bags.get_bagslots(stack))
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
end,
allow_put = function(inv, listname, index, stack, player)
if bags.get_bagslots(stack) then
return 1
else
return 0
end
end,
allow_take = function(inv, listname, index, stack, player)
if player:get_inventory():is_empty(listname.."contents")==true then
return stack:get_size(listname)
else
return 0
end
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for i=1,4 do
local bag = "bag"..i
player_inv:set_size(bag, 1)
bags_inv:set_size(bag, 1)
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
end
-- armor inventory
local armor_inv = minetest.create_detached_inventory(player:get_player_name().."_armor",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
bags.set_armor_groups(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
bags.set_armor_groups(player)
end,
allow_put = function(inv, listname, index, stack, player)
if inv:is_empty(listname) and bags.get_armor_level(stack,listname) then
return 1
else
return 0
end
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for _,v in ipairs({"boots","chest","helmet","shield"}) do
local armor = "armor_"..v
player_inv:set_size(armor, 1)
armor_inv:set_size(armor, 1)
armor_inv:set_stack(armor,1,player_inv:get_stack(armor,1))
end
-- player initial setup
player:set_inventory_formspec(bags.get_formspec(player))
bags.set_armor_groups(player)
end
-- get_bagslots
bags.get_bagslots = function(stack)
if stack then
return stack:get_definition().groups.bagslots
end
end
-- get_armor_level
bags.get_armor_level = function(stack,armor_type)
if stack then
return stack:get_definition().groups[armor_type]
end
end
-- set_armor_groups
bags.set_armor_groups = function(player)
local level
local armor_groups = {level=4,fleshy=4,snappy=4,choppy=4}
player_inv = player:get_inventory()
-- helmet
level = bags.get_armor_level(player_inv:get_stack("armor_helmet", 1),"armor_helmet")
if level~=nil then
armor_groups.level = level
end
-- chest
level = bags.get_armor_level(player_inv:get_stack("armor_chest", 1),"armor_chest")
if level~=nil then
armor_groups.fleshy = level
end
-- boots
level = bags.get_armor_level(player_inv:get_stack("armor_boots", 1),"armor_boots")
if level~=nil then
armor_groups.snappy = level
end
-- shield
level = bags.get_armor_level(player_inv:get_stack("armor_shield", 1),"armor_shield")
if level~=nil then
armor_groups.choppy = level
end
player:set_armor_groups(armor_groups)
print(dump(armor_groups))
end
-- register armor
bags.register_armor = function(name,label,material,level)
-- tools
minetest.register_tool("bags:armor_helmet_"..name, {
description = label.." Helmet",
inventory_image = "armor_helmet_"..name..".png",
groups = {armor_helmet=level},
wear = 0,
})
minetest.register_tool("bags:armor_chest_"..name, {
description = label.." Chestplate",
inventory_image = "armor_chest_"..name..".png",
groups = {armor_chest=level},
wear = 0,
})
minetest.register_tool("bags:armor_boots_"..name, {
description = label.." Boots",
inventory_image = "armor_boots_"..name..".png",
groups = {armor_boots=level},
wear = 0,
})
minetest.register_tool("bags:armor_shield_"..name, {
description = label.." Shield",
inventory_image = "armor_shield_"..name..".png",
groups = {armor_shield=level},
wear = 0,
})
-- crafts
minetest.register_craft({
output = "bags:armor_helmet_"..name,
recipe = {
{material, material, material},
{material, "", material},
{material, "", material},
},
})
minetest.register_craft({
output = "bags:armor_chest_"..name,
recipe = {
{material, material, material},
{material, material, material},
{"", material, ""},
},
})
minetest.register_craft({
output = "bags:armor_boots_"..name,
recipe = {
{material, "", material},
{material, "", material},
{material, "", material},
},
})
minetest.register_craft({
output = "bags:armor_shield_"..name,
recipe = {
{material, material, material},
{material, "", material},
{material, material, material},
},
})
end

1
bags/depends.txt Normal file
View File

@ -0,0 +1 @@
inventory_plus

140
bags/init.lua Normal file
View File

@ -0,0 +1,140 @@
--[[
Bags for Minetest
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
Source Code: https://github.com/cornernote/minetest-particles
License: GPLv3
]]--
-- get_formspec
local get_formspec = function(player,page)
if page=="bags" then
return "size[8,7.5]"
.."list[current_player;main;0,3.5;8,4;]"
.."button[0,0;2,0.5;main;Back]"
.."button[0,2;2,0.5;bag1;Bag 1]"
.."button[2,2;2,0.5;bag2;Bag 2]"
.."button[4,2;2,0.5;bag3;Bag 3]"
.."button[6,2;2,0.5;bag4;Bag 4]"
.."list[detached:"..player:get_player_name().."_bags;bag1;0.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag2;2.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag3;4.5,1;1,1;]"
.."list[detached:"..player:get_player_name().."_bags;bag4;6.5,1;1,1;]"
end
for i=1,4 do
if page=="bag"..i then
local image = player:get_inventory():get_stack("bag"..i, 1):get_definition().inventory_image
return "size[8,8.5]"
.."list[current_player;main;0,4.5;8,4;]"
.."button[0,0;2,0.5;main;Main]"
.."button[2,0;2,0.5;bags;Bags]"
.."image[7,0;1,1;"..image.."]"
.."list[current_player;bag"..i.."contents;0,1;8,3;]"
end
end
end
-- register_on_player_receive_fields
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.bags then
inventory_plus.set_inventory_formspec(player, get_formspec(player,"bags"))
return
end
for i=1,4 do
local page = "bag"..i
if fields[page] then
if player:get_inventory():get_stack(page, 1):get_definition().groups.bagslots==nil then
page = "bags"
end
inventory_plus.set_inventory_formspec(player, get_formspec(player,page))
return
end
end
end)
-- register_on_joinplayer
minetest.register_on_joinplayer(function(player)
inventory_plus.register_button(player,"bags","Bags")
local player_inv = player:get_inventory()
local bags_inv = minetest.create_detached_inventory(player:get_player_name().."_bags",{
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
player:get_inventory():set_size(listname.."contents", stack:get_definition().groups.bagslots)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
end,
allow_put = function(inv, listname, index, stack, player)
if stack:get_definition().groups.bagslots then
return 1
else
return 0
end
end,
allow_take = function(inv, listname, index, stack, player)
if player:get_inventory():is_empty(listname.."contents")==true then
return stack:get_count()
else
return 0
end
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for i=1,4 do
local bag = "bag"..i
player_inv:set_size(bag, 1)
bags_inv:set_size(bag, 1)
bags_inv:set_stack(bag,1,player_inv:get_stack(bag,1))
end
end)
-- register bag tools
minetest.register_tool("bags:small", {
description = "Small Bag",
inventory_image = "bags_small.png",
groups = {bagslots=8},
})
minetest.register_tool("bags:medium", {
description = "Medium Bag",
inventory_image = "bags_medium.png",
groups = {bagslots=16},
})
minetest.register_tool("bags:large", {
description = "Large Bag",
inventory_image = "bags_large.png",
groups = {bagslots=24},
})
-- register bag crafts
minetest.register_craft({
output = "bags:small",
recipe = {
{"", "default:stick", ""},
{"default:wood", "default:wood", "default:wood"},
{"default:wood", "default:wood", "default:wood"},
},
})
minetest.register_craft({
output = "bags:medium",
recipe = {
{"", "default:stick", ""},
{"bags:small", "bags:small", "bags:small"},
{"bags:small", "bags:small", "bags:small"},
},
})
minetest.register_craft({
output = "bags:large",
recipe = {
{"", "default:stick", ""},
{"bags:medium", "bags:medium", "bags:medium"},
{"bags:medium", "bags:medium", "bags:medium"},
},
})
-- log that we started
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))

BIN
bags/textures/alt/bag1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

BIN
bags/textures/alt/bag2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

BIN
bags/textures/alt/bag3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

BIN
bags/textures/alt/bag4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Some files were not shown because too many files have changed in this diff Show More