Doyousketch2

Minetest - Immortal effect

Feb 26th, 2018
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. playereffects.register_effect_type("immortal_effect", "Immortal", "immortal.png", {"immortal"},
  2.  
  3. function(user)
  4.     if user and user:is_player() then
  5.         local groups = user:get_armor_groups()
  6.         print('pre-set   ' ..dump(groups))
  7.  
  8.         playereffects.preset = groups
  9.         user:set_armor_groups({immortal=1})
  10.         print('post-set   ' ..dump(user:get_armor_groups()))
  11.     end
  12. end,
  13.  
  14. function(effect, user)
  15.     if user and user:is_player() then
  16.         local groups = user:get_armor_groups()
  17.         print('pre-retract   ' ..dump(groups))
  18.  
  19.         if groups.immortal then
  20.             user:set_armor_groups(playereffects.preset)
  21.         end
  22.         print('post-retract   ' ..dump(user:get_armor_groups()))
  23.     end
  24. end
  25. )
  26.  
  27. minetest.register_chatcommand("morto", {
  28.     params = "",
  29.     description = "Immortal for 20 secs.",
  30.     privs = {},
  31.     func = function(name, param)
  32.         local ret = playereffects.apply_effect_type("immortal_effect", 20, minetest.get_player_by_name(name))
  33.         notify(name, ret)
  34.     end,
  35. })
RAW Paste Data