Page 1 of 1

[Mod] Yet Another Bandage [bandage]

PostPosted: Fri Jun 17, 2016 19:11
by everamzah
Really a small mod using one cotton (farming:cotton) and two paper (default:paper) to make one bandage (bandage:bandage). If you have lost hearts, using a bandage will restore up to two of them (4 HP). Otherwise the bandage remains unused.

It's a bandage ha! I made it so that I could restore health points independent of hunger, and without using minetest.item_eat().


Update: If you get hurt and have fewer than two hearts, and there's at least one bandage in your hotbar, then it will be automatically applied.

License: GPL3
Download: GitHub or master.zip

Image

Image

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 10:51
by azekill_DIABLO
cool! it's an apple with a texture no?

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 10:55
by everamzah
It's a bandage ha! I made it so that I could restore health points independent of hunger, and without using minetest.item_eat().

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 11:11
by azekill_DIABLO
ok! better now!you should say it in your 1st post

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 11:50
by everamzah
Ok! It is done. I thought, by the way, briefly, that it would be interesting to automatically apply a bandage if you have fewer than two hearts and you're holding bandages in your hotbar.

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 12:04
by azekill_DIABLO
do this with
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_player_hpchange(function(player, hp_change)
   if hp_change>2 then

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sat Jun 18, 2016 20:39
by everamzah
Okay, I got something. hp_change is a negative when it's damage. I also changed the license to GPL3.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_player_hpchange(function(player, hp_change)
   if hp_change >= 0 then
      return hp_change
   end
   local hp = player:get_hp()
   if hp + hp_change < 4 and hp + hp_change > 0 then
      for i, v in pairs(player:get_inventory():get_list("main")) do
         if i <= 8 then
            if v:get_name() == "bandage:bandage" then
               minetest.chat_send_player(player:get_player_name(), "Automatically applying bandage")
               v:take_item(1)
               player:get_inventory():set_stack("main", i, v)
               hp_change = hp_change + 2
            end
         end
      end
   end
   return hp_change
end, true)


Not sure how well this will work in combat. Will test now.

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sun Jun 19, 2016 09:26
by cd2
everamzah wrote:Okay, I got something. hp_change is a negative when it's damage. I also changed the license to GPL3.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_player_hpchange(function(player, hp_change)
   if hp_change >= 0 then
      return hp_change
   end
   local hp = player:get_hp()
   if hp + hp_change < 4 and hp + hp_change > 0 then
      for i, v in pairs(player:get_inventory():get_list("main")) do
         if i <= 8 then
            if v:get_name() == "bandage:bandage" then
               minetest.chat_send_player(player:get_player_name(), "Automatically applying bandage")
               v:take_item(1)
               player:get_inventory():set_stack("main", i, v)
               hp_change = hp_change + 2
            end
         end
      end
   end
   return hp_change
end, true)


Not sure how well this will work in combat. Will test now.


+1

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Sun Jun 19, 2016 10:40
by azekill_DIABLO
look a fork!
i've done it yesterday. i'm planning to add a timer feature

Re: [Mod] Yet Another Bandage [bandage]

PostPosted: Wed Nov 09, 2016 17:04
by Fixerol