Added maxhp

master
NathanSalapat 2020-07-09 08:24:09 -05:00
parent b8e59ecdad
commit 903a57bf57
12 changed files with 83 additions and 4 deletions

View File

@ -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')
}
})

View File

@ -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({

View File

@ -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({

0
mods/maxhp/food.lua Normal file
View File

12
mods/maxhp/functions.lua Normal file
View File

@ -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

28
mods/maxhp/init.lua Normal file
View File

@ -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)
--]]

6
mods/maxhp/license.txt Normal file
View File

@ -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.

0
mods/maxhp/mod.conf Normal file
View File

10
mods/maxhp/potions.lua Normal file
View File

@ -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
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

View File

@ -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

View File

@ -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.',