Skip to content

Instantly share code, notes, and snippets.

@PilzAdam
Created September 14, 2012 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PilzAdam/3722598 to your computer and use it in GitHub Desktop.
Save PilzAdam/3722598 to your computer and use it in GitHub Desktop.
if minetest.setting_getbool("313hummer_fan") and minetest.setting_get("music_frequency") and tonumber(minetest.setting_get("music_frequency")) then
local music = {
{name="313hummer_music_echos", length=26+2*60},
{name="313hummer_music_", length=0},
{name="313hummer_music_", length=0},
{name="313hummer_music_", length=0},
{name="313hummer_music_", length=0},
{name="313hummer_music_", length=0},
{name="313hummer_music_", length=0},
}
local time = 0
local playing = false
minetest.register_globalstep(function(dtime)
if playing then
return
end
time = time+dtime
if time < 10 then
return
end
time = 0
if math.random(1, 100) <= tonumber(minetest.setting_get("music_frequency")) then
local track = music[math.random(1, #music)]
minetest.sound_play(track.name)
playing = true
minetest.after(track.length, function()
playing = false
end)
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment