apply horseshoe overlay to horse when shoes applied

This commit is contained in:
TenPlus1 2020-03-27 10:21:08 +00:00
parent 4b6fb606a6
commit 5bf8ecbbf1
5 changed files with 23 additions and 8 deletions

View File

@ -81,8 +81,11 @@ mobs:register_mob("mob_horse:horse", {
-- drop saddle when horse is killed while riding -- drop saddle when horse is killed while riding
-- also detach from horse properly -- also detach from horse properly
if self.driver then if self.driver then
minetest.add_item(pos, "mobs:saddle") minetest.add_item(pos, "mobs:saddle")
mobs.detach(self.driver, {x = 1, y = 0, z = 1}) mobs.detach(self.driver, {x = 1, y = 0, z = 1})
self.saddle = nil self.saddle = nil
end end
@ -166,7 +169,8 @@ mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1)
-- horseshoe helper function -- horseshoe helper function
local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse) local apply_shoes = function(name, itemstack, obj, shoes, speed, jump,
reverse, overlay)
if obj.type ~= "object" then return end if obj.type ~= "object" then return end
@ -185,6 +189,17 @@ local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse)
ent.accel = speed ent.accel = speed
ent.shoed = shoes ent.shoed = shoes
-- apply horseshoe overlay to current horse texture
if overlay then
local ov = ent.base_texture
ov[1] = ov[1] .. "^" .. overlay
mob:set_properties({textures = ov})
end
-- show horse speed and jump stats with shoes fitted
minetest.chat_send_player(name, S("Horse shoes fitted -") minetest.chat_send_player(name, S("Horse shoes fitted -")
.. S(" speed: ") .. speed .. S(" speed: ") .. speed
.. S(" , jump height: ") .. jump .. S(" , jump height: ") .. jump
@ -203,7 +218,7 @@ minetest.register_craftitem(":mobs:horseshoe_steel", {
inventory_image = "mobs_horseshoe_steel.png", inventory_image = "mobs_horseshoe_steel.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing, return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
"mobs:horseshoe_steel", 7, 4, 2) "mobs:horseshoe_steel", 7, 4, 2, "mobs_horseshoe_steelo.png")
end, end,
}) })
@ -222,7 +237,7 @@ minetest.register_craftitem(":mobs:horseshoe_bronze", {
inventory_image = "mobs_horseshoe_bronze.png", inventory_image = "mobs_horseshoe_bronze.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing, return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
"mobs:horseshoe_bronze", 7, 4, 4) "mobs:horseshoe_bronze", 7, 4, 4, "mobs_horseshoe_bronzeo.png")
end, end,
}) })
@ -241,7 +256,7 @@ minetest.register_craftitem(":mobs:horseshoe_mese", {
inventory_image = "mobs_horseshoe_mese.png", inventory_image = "mobs_horseshoe_mese.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing, return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
"mobs:horseshoe_mese", 9, 5, 8) "mobs:horseshoe_mese", 9, 5, 8, "mobs_horseshoe_meseo.png")
end, end,
}) })
@ -260,7 +275,7 @@ minetest.register_craftitem(":mobs:horseshoe_diamond", {
inventory_image = "mobs_horseshoe_diamond.png", inventory_image = "mobs_horseshoe_diamond.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
return apply_shoes(user:get_player_name(), itemstack, pointed_thing, return apply_shoes(user:get_player_name(), itemstack, pointed_thing,
"mobs:horseshoe_diamond", 10, 6, 6) "mobs:horseshoe_diamond", 10, 6, 6, "mobs_horseshoe_diamondo.png")
end, end,
}) })

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B