Changes to music and headbars

This commit is contained in:
KaadmY 2017-05-11 16:05:36 -07:00
parent 5c5f438b79
commit e5be49c0b6
6 changed files with 20 additions and 22 deletions

View File

@ -49,7 +49,9 @@ bed_enabled = true
# if music players are usable # if music players are usable
music_enable = true music_enable = true
music_track = music_greyarms music_track = music_catsong
music_track_length = 30.0
music_volume = 0.8
# if dynamically changing weather is enabled # if dynamically changing weather is enabled
weather_enable = true weather_enable = true

View File

@ -5,12 +5,12 @@
headbars = {} headbars = {}
local damage_enable = minetest.setting_getbool("enable_damage") local enable_damage = minetest.setting_getbool("enable_damage")
local enable_headbars = minetest.setting_getbool("headbars_enable") local enable_headbars = minetest.setting_getbool("headbars_enable")
if enable_headbars == nil then enable_headbars = true end if enable_headbars == nil then enable_headbars = true end
local headbars_scale = tonumber(minetest.setting_get("headbars_scale")) or 1 local headbars_scale = tonumber(minetest.setting_get("headbars_scale")) or 1.0
function headbars.get_sprite(icon, background, max, amt) function headbars.get_sprite(icon, background, max, amt)
local img = "[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png" local img = "[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png"
@ -48,25 +48,21 @@ minetest.register_entity(
collisionbox = {0, 0, 0, 0, 0, 0}, collisionbox = {0, 0, 0, 0, 0, 0},
on_step = function(self, dtime) on_step = function(self, dtime)
local ent = self.wielder local ent = self.wielder
if ent == nil or (minetest.get_player_by_name(ent:get_player_name(0)) == nil) then if ent == nil or (minetest.get_player_by_name(ent:get_player_name(0)) == nil) then
self.object:remove() self.object:remove()
return return
end end
local hp = ent:get_hp() local hp = ent:get_hp()
if ent:is_player() then self.object:set_properties({textures = {headbars.get_sprite("heart.png", "headbars_heart_bg.png", 20, hp)}})
self.object:set_properties({textures = {headbars.get_sprite("heart.png", "headbars_heart_bg.png", 20, hp)}}) end,
else })
self.object:set_properties({textures = {headbars.get_sprite("heart.png", "headbars_heart_bg.png", 20, hp)}})
end
end,
})
function headbars.attach_hpbar(to) function headbars.attach_hpbar(to)
if not damage_enable then return end if not enable_damage then return end
if not enable_headbars then return end if not enable_headbars then return end
local pos = to:getpos() local pos = to:getpos()
@ -74,7 +70,7 @@ function headbars.attach_hpbar(to)
if bar == nil then return end if bar == nil then return end
-- local attach_pos = {x = 0, y = 0, z = 0} -- local attach_pos = {x = 0, y = 0, z = 0}
local attach_pos = {x = 0, y = 9, z = 0} local attach_pos = {x = 0, y = 9, z = 0}
bar:set_attach(to, "", attach_pos, {x = 0, y = 0, z = 0}) bar:set_attach(to, "", attach_pos, {x = 0, y = 0, z = 0})

View File

@ -4,7 +4,6 @@ By Kaadmy, for Pixture
Music license: Music license:
music_catsong: Dan Knoflicek(CC0) music_catsong: Dan Knoflicek(CC0)
music_wonderful_nightmare.ogg: SpiderDave(CC0)
music_greyarms.ogg: Tozan(CC0) music_greyarms.ogg: Tozan(CC0)
Texture license: CC BY-SA 4.0 Texture license: CC BY-SA 4.0

View File

@ -6,6 +6,7 @@
music = {} music = {}
music.default_track = minetest.setting_get("music_track") or "music_catsong" music.default_track = minetest.setting_get("music_track") or "music_catsong"
music.track_length = tonumber(minetest.setting_get("music_track_length")) or 30.0
music.volume = tonumber(minetest.setting_get("music_volume")) or 1.0 music.volume = tonumber(minetest.setting_get("music_volume")) or 1.0
music.players = {} -- music players music.players = {} -- music players
@ -66,7 +67,7 @@ if minetest.setting_getbool("music_enable") then
return return
end end
if music.players[dp]["timer"] > 28 then if music.players[dp]["timer"] > music.track_length then
music.start(pos) music.start(pos)
end end
end end

Binary file not shown.