diff --git a/mods/epic/doc.lua b/mods/epic/doc.lua index aac9ad6..50c6b69 100644 --- a/mods/epic/doc.lua +++ b/mods/epic/doc.lua @@ -46,3 +46,12 @@ doc.add_entry("epic_server", "chat", { 'With the bridge disabled your chat messages will not be sent to discord, and you won\'t see any messages sent from discord.') } }) + +doc.add_entry("epic_server", "maxhp", { + name = ("Max HP"), + data = { text = ('In an attempt to dissuade people from killing themselves in lava to make a messes on the server I wrote this mod. Every time you die you\'ll loose one of your max HP down to 25.\n\n'.. + 'You can gain max HP back by consuming a variety of items, with more to be added soon.\n'.. + 'Eating a chocolate block will increase your max HP by 1, up to a max of 45.\n'.. + 'Eating a golden carrot will increase your max HP by 1, up to a max of 60.\n') + } +}) diff --git a/mods/farming/crops/carrot.lua b/mods/farming/crops/carrot.lua index 00ecb14..62c0b41 100644 --- a/mods/farming/crops/carrot.lua +++ b/mods/farming/crops/carrot.lua @@ -19,9 +19,14 @@ minetest.register_craftitem("farming:carrot", { -- golden carrot minetest.register_craftitem("farming:carrot_gold", { + _doc_items_longdesc = "Fills 20 satiation, and increases max HP by 1 up to 60.", description = S("Golden Carrot"), inventory_image = "farming_carrot_gold.png", - on_use = minetest.item_eat(6), + on_use = function(itemstack, user, pointed_thing) + maxhp.max_hp_change(user, 1, 60) + local eat_func = minetest.item_eat(20) + return eat_func(itemstack, user, pointed_thing) + end, }) minetest.register_craft({ diff --git a/mods/farming/crops/cocoa.lua b/mods/farming/crops/cocoa.lua index 032c4b0..4f03e50 100644 --- a/mods/farming/crops/cocoa.lua +++ b/mods/farming/crops/cocoa.lua @@ -110,12 +110,17 @@ minetest.register_craft( { -- chocolate block minetest.register_node("farming:chocolate_block", { + _doc_items_longdesc = "Fills 27 satiation, and increases max HP by 1 up to 45.", description = S("Chocolate Block"), tiles = {"farming_chocolate_block.png"}, is_ground_content = false, groups = {cracky = 2, oddly_breakable_by_hand = 2}, sounds = default.node_sound_stone_defaults(), - on_use = minetest.item_eat(27), + on_use = function(itemstack, user, pointed_thing) + maxhp.max_hp_change(user, 1, 45) + local eat_func = minetest.item_eat(27) + return eat_func(itemstack, user, pointed_thing) + end, }) minetest.register_craft({ diff --git a/mods/maxhp/food.lua b/mods/maxhp/food.lua new file mode 100644 index 0000000..e69de29 diff --git a/mods/maxhp/functions.lua b/mods/maxhp/functions.lua new file mode 100644 index 0000000..b33dc47 --- /dev/null +++ b/mods/maxhp/functions.lua @@ -0,0 +1,12 @@ +function maxhp.max_hp_change(player, change, cap) + local name = player:get_player_name() + local max_hp = tonumber(maxhp.storage:get_string(name..'_max_hp')) + local new_max_hp = max_hp + change + if new_max_hp <= cap then + player:set_properties({hp_max = new_max_hp}) + maxhp.storage:set_string(name..'_max_hp', new_max_hp) + return true + else + return false + end +end diff --git a/mods/maxhp/init.lua b/mods/maxhp/init.lua new file mode 100644 index 0000000..05b11eb --- /dev/null +++ b/mods/maxhp/init.lua @@ -0,0 +1,28 @@ +maxhp = {} +maxhp.storage = minetest.get_mod_storage() + +dofile(minetest.get_modpath('maxhp')..'/functions.lua') +dofile(minetest.get_modpath('maxhp')..'/potions.lua') + +minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + local max_hp = tonumber(maxhp.storage:get_string(name..'_max_hp')) + if max_hp == nil then + maxhp.storage:set_string(name..'_max_hp', 50) + player:set_properties({hp_max = 50}) + else + player:set_properties({hp_max = max_hp}) + end +end) + +--[[ +minetest.register_on_dieplayer(function(player) + local name = player:get_player_name() + local max_hp = tonumber(maxhp.storage:get_string(name..'max_hp')) + local new_max_hp = max_hp - 1 + if new_max_hp >= 25 then + player:set_properties({hp_max = new_max_hp}) + maxhp.storage:set_string(name..'max_hp', new_max_hp) + end +end) +--]] diff --git a/mods/maxhp/license.txt b/mods/maxhp/license.txt new file mode 100644 index 0000000..a33bb65 --- /dev/null +++ b/mods/maxhp/license.txt @@ -0,0 +1,6 @@ +Code is licensed MIT, Media CC by SA 4.0 +Copyright 2020 Nathan Salapat + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/mods/maxhp/mod.conf b/mods/maxhp/mod.conf new file mode 100644 index 0000000..e69de29 diff --git a/mods/maxhp/potions.lua b/mods/maxhp/potions.lua new file mode 100644 index 0000000..61156be --- /dev/null +++ b/mods/maxhp/potions.lua @@ -0,0 +1,10 @@ +minetest.register_craftitem('maxhp:lifeforce', { + _doc_items_longdesc = "Increases max HP by 5 up to 50.", + description = 'Life Force', + inventory_image = 'maxhp_lifeforce.png', + on_use = function(itemstack, user, pointed_thing) + if maxhp.max_hp_change(user, 5, 50) then + itemstack:take_item(1); return itemstack + end + end +}) diff --git a/mods/maxhp/textures/maxhp_lifeforce.png b/mods/maxhp/textures/maxhp_lifeforce.png new file mode 100644 index 0000000..a367886 Binary files /dev/null and b/mods/maxhp/textures/maxhp_lifeforce.png differ diff --git a/mods/spawn/commands.lua b/mods/spawn/commands.lua index c38ddcf..687ad3e 100644 --- a/mods/spawn/commands.lua +++ b/mods/spawn/commands.lua @@ -45,7 +45,6 @@ local function has_interact(player) end minetest.register_on_joinplayer(function(player) - player:set_properties({hp_max = 50}) player:set_properties({breath_max = 40}) player:set_breath(40) if has_interact(player) then diff --git a/mods/spawn/news.lua b/mods/spawn/news.lua index 5c1806c..195b126 100644 --- a/mods/spawn/news.lua +++ b/mods/spawn/news.lua @@ -1,6 +1,11 @@ local news = { + '7/9/20', + 'Added maxhp. You can learn more about it in the encyclopedia, or by running /helpform', + '', '7/8/20', - 'Removed playeranim, added headanim.', + 'Added Orange and Banana trees, Thanks MisterE.', + 'Tweaked some recipes in the spinning wheel.', + 'Removed a few mods, hopefully will add them back soon. Trying to figure out what\'s causing the lag.', '', '7/7/20', 'Added pedestals.',