diff --git a/minetest.conf b/minetest.conf index ad43133..ea82a37 100644 --- a/minetest.conf +++ b/minetest.conf @@ -23,6 +23,9 @@ default_privs = interact, shout, spawn, fast # if you're given the inital stuff; a stone pick and 10 torches give_initial_stuff = false +# if you drop items in your inventory when you die +drop_items_on_die = true + # mob stuff mobs_enable_blood = false @@ -50,6 +53,10 @@ testing_enable = false hunger_enable = true hunger_step = 2 +# headbars +headbars_enable = true +headbars_scale = 1 + # ambience noises flowing_water_sounds = true diff --git a/mods/armor/init.lua b/mods/armor/init.lua index e509662..4f4807c 100644 --- a/mods/armor/init.lua +++ b/mods/armor/init.lua @@ -21,6 +21,8 @@ armor.slots = {"helmet", "chestplate", "boots"} local form_armor = default.ui.get_page("core_2part") default.ui.register_page("core_armor", form_armor) +local enable_drop = minetest.setting_getbool("drop_items_on_die") or false + local armor_timer = 10 function armor.is_armor(itemname) @@ -147,7 +149,7 @@ local function on_die(player) z = pos.z + math.random(-0.2, 0.2) } - drop = minetest.add_item(rpos, item) + local drop = minetest.add_item(rpos, item) if drop then drop:setvelocity( @@ -157,6 +159,9 @@ local function on_die(player) z = math.random(-0.3, 0.3), }) end + + item:clear() + inv:set_stack("armor_" .. slot, 1, item) end end @@ -251,7 +256,9 @@ end minetest.register_on_newplayer(on_newplayer) minetest.register_on_joinplayer(on_joinplayer) -minetest.register_on_dieplayer(on_die) +if enable_drop then + minetest.register_on_dieplayer(on_die) +end minetest.register_globalstep(step) local form_armor = default.ui.get_page("core_2part") diff --git a/mods/drop_items_on_die/README.txt b/mods/drop_items_on_die/README.txt new file mode 100644 index 0000000..48e401c --- /dev/null +++ b/mods/drop_items_on_die/README.txt @@ -0,0 +1,7 @@ +Drop items on die mod +===================== +By Kaadmy, for Pixture + +Players drop their inventory when they die + +Source license: WTFPL diff --git a/mods/drop_items_on_die/depends.txt b/mods/drop_items_on_die/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/drop_items_on_die/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/drop_items_on_die/init.lua b/mods/drop_items_on_die/init.lua new file mode 100644 index 0000000..c8934ae --- /dev/null +++ b/mods/drop_items_on_die/init.lua @@ -0,0 +1,45 @@ +-- +-- Drop items on die mod +-- By Kaadmy, for Pixture +-- + +local enable_drop = minetest.setting_getbool("drop_items_on_die") or false + +local function on_die(player) + local pos = player:getpos() + + local inv = player:get_inventory() + + for i = 1, inv:get_size("main") do + local item = inv:get_stack("main", i) + + local rpos = { + x = pos.x + math.random(-0.3, 0.3), + y = pos.y, + z = pos.z + math.random(-0.3, 0.3) + } + + local drop = minetest.add_item(rpos, item) + + if drop ~= nil then + local x = math.random(1, 5) + if math.random(1, 2) == 1 then + x = -x + end + local z = math.random(1, 5) + if math.random(1, 2) == 1 then + z = -z + end + drop:setvelocity({x = 1 / x, y = drop:getvelocity().y, z = 1 / z}) + end + + item:clear() + inv:set_stack("main", i, item) + end +end + +if enable_drop then + minetest.register_on_dieplayer(on_die) +end + +default.log("mod:drop_items_on_die", "loaded") \ No newline at end of file diff --git a/mods/headbars/README.txt b/mods/headbars/README.txt new file mode 100644 index 0000000..83496b0 --- /dev/null +++ b/mods/headbars/README.txt @@ -0,0 +1,7 @@ +Headbars mod +============ +By Kaadmy, for Pixture + +Puts a health bar above players + +Source license: WTFPL diff --git a/mods/headbars/depends.txt b/mods/headbars/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/headbars/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/headbars/init.lua b/mods/headbars/init.lua new file mode 100644 index 0000000..b829663 --- /dev/null +++ b/mods/headbars/init.lua @@ -0,0 +1,84 @@ +-- +-- Headbars mod +-- By Kaadmy, for Pixture +-- + +headbars = {} + +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 + +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 + end + end + + img = img .. "^([combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png" + + for i = 0, max / 2 do + if i < (amt - 1) / 2 then + img = img .. "^[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:" .. (i * 16) .. ",0=" .. icon + elseif i < amt / 2 then + img = img .. "^[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:" .. (i * 16) .. ",0=" .. icon + img = img .. "^[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:" .. (i * 16) .. ",0=headbars_half.png" + end + end + + img = img .. "^[makealpha:255,0,255)" + + return img +end + +minetest.register_entity( + "headbars:hpbar", + { + visual = "sprite", + visual_size = {x = 1 * headbars_scale, y = 0.1 * headbars_scale, z = 1}, + textures = {headbars.get_sprite("heart.png", "ui_null.png", 20, 20)}, + + physical = false, + collisionbox = {0, 0, 0, 0, 0, 0}, + + on_step = function(self, dtime) + local ent = self.wielder + + if ent == nil then + self.object:remove() + return + end + + 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, + }) + +function headbars.attach_hpbar(to) + if not enable_headbars then return end + + local pos = to:getpos() + local bar = minetest.add_entity(pos, "headbars:hpbar") + + if bar == nil then return end + + local attach_pos = {x = 0, y = 0, z = 0} + attach_pos = {x = 0, y = 9, z = 0} + + bar:set_attach(to, "", attach_pos, {x = 0, y = 0, z = 0}) + bar = bar:get_luaentity() + bar.wielder = to +end + +minetest.register_on_joinplayer(headbars.attach_hpbar) + +default.log("mod:headbars", "loaded") \ No newline at end of file diff --git a/mods/headbars/textures/headbars_half.png b/mods/headbars/textures/headbars_half.png new file mode 100644 index 0000000..aed8671 Binary files /dev/null and b/mods/headbars/textures/headbars_half.png differ diff --git a/mods/headbars/textures/headbars_half.xcf b/mods/headbars/textures/headbars_half.xcf new file mode 100644 index 0000000..a739917 Binary files /dev/null and b/mods/headbars/textures/headbars_half.xcf differ diff --git a/mods/headbars/textures/headbars_heart_bg.png b/mods/headbars/textures/headbars_heart_bg.png new file mode 100644 index 0000000..05897aa Binary files /dev/null and b/mods/headbars/textures/headbars_heart_bg.png differ diff --git a/mods/headbars/textures/headbars_heart_bg.xcf b/mods/headbars/textures/headbars_heart_bg.xcf new file mode 100644 index 0000000..73185f0 Binary files /dev/null and b/mods/headbars/textures/headbars_heart_bg.xcf differ diff --git a/mods/hunger/init.lua b/mods/hunger/init.lua index 259504f..96a9d89 100644 --- a/mods/hunger/init.lua +++ b/mods/hunger/init.lua @@ -234,7 +234,7 @@ if minetest.setting_getbool("enable_damage") and minetest.setting_getbool("hunge if player_health_step[name] == nil then player_health_step[name] = 0 end player_health_step[name] = player_health_step[name] + 1 - if player_health_step[name] >= 5 and player:get_hp() < 20 and hunger.hunger[name] >= 16 then + if hp > 0 and hp < 20 and player_health_step[name] >= 5 and hunger.hunger[name] >= 16 then player_health_step[name] = 0 player:set_hp(hp+1) end