forked from minetest-mods/armor_monoid
Add immortal and fall_damage_add_percent armor groups (#3)
This change adds special handling for these armor groups, ensuring that their default values will remain as they are while also allowing mods to manage these groups via Armor Monoid. Beware that the value range does not exactly correspond to the Luanti-provided API.
This commit is contained in:
15
init.lua
15
init.lua
@ -1,7 +1,11 @@
|
||||
|
||||
armor_monoid = {}
|
||||
|
||||
local armor_groups = { fleshy = 100 }
|
||||
local armor_groups = {
|
||||
fleshy = 100,
|
||||
fall_damage_add_percent = 100,
|
||||
immortal = 1,
|
||||
}
|
||||
|
||||
armor_monoid.registered_groups = armor_groups
|
||||
|
||||
@ -71,6 +75,15 @@ armor_monoid.monoid = player_monoids.make_monoid({
|
||||
end
|
||||
end
|
||||
|
||||
-- fall_damage_add_percent is a special armor group that has an inherent
|
||||
-- value of 0 rather than 100, so its final value is offset by -100 here
|
||||
final.fall_damage_add_percent = final.fall_damage_add_percent - 100
|
||||
|
||||
-- immortal is a special armor group that must be either 0 or 1 to indicate
|
||||
-- mortality or immortality, respectively, so its final value is constrained
|
||||
-- here
|
||||
final.immortal = final.immortal > 1 and 1 or 0
|
||||
|
||||
join_handled[player:get_player_name()] = true
|
||||
|
||||
player:set_armor_groups(final)
|
||||
|
Reference in New Issue
Block a user