Skip to content

Commit

Permalink
add physics overrides to armor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bremaweb committed Dec 21, 2013
1 parent 0b3deea commit 681bf25
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion 3d_armor/armor.lua
Expand Up @@ -8,6 +8,7 @@ end
armor = {
player_hp = {},
elements = {"head", "torso", "legs", "feet"},
physics = {"jump","speed","gravity"},
formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,4.5;8,4;]"
.."list[detached:player_name_armor;armor_head;3,0;1,1;]"
Expand Down Expand Up @@ -51,6 +52,8 @@ armor.set_player_armor = function(self, player)
local items = 0
local textures = {}
local elements = {}
local has_physics = false
local physics_o = {speed=1,gravity=1,jump=1}
for i, v in ipairs(self.elements) do
local stack = player_inv:get_stack("armor_"..v, 1)
local level = stack:get_definition().groups["armor_"..v]
Expand All @@ -62,7 +65,18 @@ armor.set_player_armor = function(self, player)
state = state + stack:get_wear()
items = items + 1
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

player:set_physics_override(physics_o)

if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9
end
Expand Down Expand Up @@ -230,7 +244,7 @@ minetest.register_on_joinplayer(function(player)
armor.textures[name].skin = "player_"..name..".png"
end
end
minetest.after(0, function(player)
minetest.after(10, function(player)
armor:set_player_armor(player)
end, player)
end)
Expand Down

0 comments on commit 681bf25

Please sign in to comment.