mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-29 23:43:42 +01:00
add physics overrides to armor
This commit is contained in:
parent
0b3deea513
commit
681bf25505
@ -8,6 +8,7 @@ end
|
|||||||
armor = {
|
armor = {
|
||||||
player_hp = {},
|
player_hp = {},
|
||||||
elements = {"head", "torso", "legs", "feet"},
|
elements = {"head", "torso", "legs", "feet"},
|
||||||
|
physics = {"jump","speed","gravity"},
|
||||||
formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
|
formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
|
||||||
.."list[current_player;main;0,4.5;8,4;]"
|
.."list[current_player;main;0,4.5;8,4;]"
|
||||||
.."list[detached:player_name_armor;armor_head;3,0;1,1;]"
|
.."list[detached:player_name_armor;armor_head;3,0;1,1;]"
|
||||||
@ -51,6 +52,8 @@ armor.set_player_armor = function(self, player)
|
|||||||
local items = 0
|
local items = 0
|
||||||
local textures = {}
|
local textures = {}
|
||||||
local elements = {}
|
local elements = {}
|
||||||
|
local has_physics = false
|
||||||
|
local physics_o = {speed=1,gravity=1,jump=1}
|
||||||
for i, v in ipairs(self.elements) do
|
for i, v in ipairs(self.elements) do
|
||||||
local stack = player_inv:get_stack("armor_"..v, 1)
|
local stack = player_inv:get_stack("armor_"..v, 1)
|
||||||
local level = stack:get_definition().groups["armor_"..v]
|
local level = stack:get_definition().groups["armor_"..v]
|
||||||
@ -62,7 +65,18 @@ armor.set_player_armor = function(self, player)
|
|||||||
state = state + stack:get_wear()
|
state = state + stack:get_wear()
|
||||||
items = items + 1
|
items = items + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for kk,vv in ipairs(self.physics) do
|
||||||
|
local o_value = stack:get_definition().groups["physics_"..vv]
|
||||||
|
if ( o_value ~= nil ) then
|
||||||
|
physics_o[vv] = physics_o[vv] + o_value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
player:set_physics_override(physics_o)
|
||||||
|
|
||||||
if minetest.get_modpath("shields") then
|
if minetest.get_modpath("shields") then
|
||||||
armor_level = armor_level * 0.9
|
armor_level = armor_level * 0.9
|
||||||
end
|
end
|
||||||
@ -230,7 +244,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
armor.textures[name].skin = "player_"..name..".png"
|
armor.textures[name].skin = "player_"..name..".png"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.after(0, function(player)
|
minetest.after(10, function(player)
|
||||||
armor:set_player_armor(player)
|
armor:set_player_armor(player)
|
||||||
end, player)
|
end, player)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user