Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
amen = {}
amen.scale = {
[1] = 0.43,
[2] = 0.78,
[3] = 0.92,
[4] = 1.3,
[5] = 1.53,
[6] = 1.75,
[7] = 1.97,
[8] = 2.42,
[9] = 2.64,
[10] = 2.85,
}
amen.pos = {}
amen.seq = 0.0
amen.play = function(player, offset)
local p = player:get_pos()
if vector.distance(p, amen.pos) > 1.45 then
local h = minetest.sound_play("amen_amen", {object = player, offset = offset})
minetest.after(amen.scale[1], minetest.sound_stop, h)
local d = vector.direction(p, amen.pos)
d.x = math.floor(d.x)
d.z = math.floor(d.z)
local dir = player:get_player_control_bits()
if dir ~= 1 then
dir = -1
end
amen.seq = amen.seq + dir
if amen.seq > #amen.scale then
amen.seq = 0
elseif amen.seq < 0 then
amen.seq = #amen.scale - 1
end
amen.pos = p
end
minetest.after(minetest.settings:get("dedicated_server_step"), amen.play, player, amen.seq)
end
minetest.register_on_joinplayer(function(player)
if not minetest.is_singleplayer() then
minetest.log("action", "Amen error, cannot load multiplayer environment!")
return minetest.request_shutdown("Amen error, cannot load multiplayer environment!")
end
amen.pos = player:get_pos()
minetest.after(minetest.settings:get("dedicated_server_step"), amen.play, player, 0.0)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.