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
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
weather_enable = true

View File

@ -5,16 +5,16 @@
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")
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)
local img = "[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png"
if amt < max then
for i = 0, max / 2 do
img = img .. "^[combine:16x16:0,0=ui_null.png:" .. (i * 16) .. ",0=" .. background
@ -48,25 +48,21 @@ minetest.register_entity(
collisionbox = {0, 0, 0, 0, 0, 0},
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
self.object:remove()
return
end
if ent == nil or (minetest.get_player_by_name(ent:get_player_name(0)) == nil) then
self.object:remove()
return
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)}})
else
self.object:set_properties({textures = {headbars.get_sprite("heart.png", "headbars_heart_bg.png", 20, hp)}})
end
end,
})
self.object:set_properties({textures = {headbars.get_sprite("heart.png", "headbars_heart_bg.png", 20, hp)}})
end,
})
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
local pos = to:getpos()
@ -74,7 +70,7 @@ function headbars.attach_hpbar(to)
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}
bar:set_attach(to, "", attach_pos, {x = 0, y = 0, z = 0})
@ -83,4 +79,4 @@ function headbars.attach_hpbar(to)
end
minetest.register_on_joinplayer(headbars.attach_hpbar)
default.log("mod:headbars", "loaded")
default.log("mod:headbars", "loaded")

View File

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

View File

@ -6,6 +6,7 @@
music = {}
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.players = {} -- music players
@ -66,7 +67,7 @@ if minetest.setting_getbool("music_enable") then
return
end
if music.players[dp]["timer"] > 28 then
if music.players[dp]["timer"] > music.track_length then
music.start(pos)
end
end

Binary file not shown.