From 5bf8ecbbf131eece5f08698f1147ac016c8d84cf Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 27 Mar 2020 10:21:08 +0000 Subject: [PATCH 1/5] apply horseshoe overlay to horse when shoes applied --- init.lua | 31 ++++++++++++++++++++------- textures/mobs_horseshoe_bronzeo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_diamondo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_meseo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_steelo.png | Bin 0 -> 106 bytes 5 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 textures/mobs_horseshoe_bronzeo.png create mode 100644 textures/mobs_horseshoe_diamondo.png create mode 100644 textures/mobs_horseshoe_meseo.png create mode 100644 textures/mobs_horseshoe_steelo.png diff --git a/init.lua b/init.lua index 711e40b..370ba53 100644 --- a/init.lua +++ b/init.lua @@ -81,9 +81,12 @@ mobs:register_mob("mob_horse:horse", { -- drop saddle when horse is killed while riding -- also detach from horse properly if self.driver then + minetest.add_item(pos, "mobs:saddle") + mobs.detach(self.driver, {x = 1, y = 0, z = 1}) -self.saddle = nil + + self.saddle = nil end -- drop any horseshoes added @@ -127,7 +130,7 @@ self.saddle = nil minetest.add_item(clicker:get_pos(), "mobs:saddle") end -self.saddle = nil + self.saddle = nil -- attach player to horse elseif (not self.driver and not self.child @@ -142,7 +145,7 @@ self.saddle = nil inv:remove_item("main", "mobs:saddle") end -self.saddle = true + self.saddle = true end end @@ -166,7 +169,8 @@ mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1) -- 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 @@ -185,6 +189,17 @@ local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse) ent.accel = speed 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 -") .. S(" speed: ") .. speed .. S(" , jump height: ") .. jump @@ -203,7 +218,7 @@ minetest.register_craftitem(":mobs:horseshoe_steel", { inventory_image = "mobs_horseshoe_steel.png", on_use = function(itemstack, user, 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, }) @@ -222,7 +237,7 @@ minetest.register_craftitem(":mobs:horseshoe_bronze", { inventory_image = "mobs_horseshoe_bronze.png", on_use = function(itemstack, user, 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, }) @@ -241,7 +256,7 @@ minetest.register_craftitem(":mobs:horseshoe_mese", { inventory_image = "mobs_horseshoe_mese.png", on_use = function(itemstack, user, 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, }) @@ -260,7 +275,7 @@ minetest.register_craftitem(":mobs:horseshoe_diamond", { inventory_image = "mobs_horseshoe_diamond.png", on_use = function(itemstack, user, 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, }) diff --git a/textures/mobs_horseshoe_bronzeo.png b/textures/mobs_horseshoe_bronzeo.png new file mode 100644 index 0000000000000000000000000000000000000000..7285e25cd80d0e2e63bcaab6c9a692b3a62a4eff GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR>YvLqAOMH~OyN0Tf{@ z3GxeOaCmkj4agDlba4!kxSX7@KyJeS`i8_Ej0{~JjQ6+PiZ}$6W$<+Mb6Mw<&;$TK Ci5@2a literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_diamondo.png b/textures/mobs_horseshoe_diamondo.png new file mode 100644 index 0000000000000000000000000000000000000000..166f704f1f199f11e5a1a567e999078398a2e704 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR=>{hZbJApe+y+4isT5 z3GxeOaCmkj4agDlba4!kxSX7@KyJeS`i8_Ej0{~JjQ6+PiZ}$6W$<+Mb6Mw<&;$TL CsU9N$ literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_meseo.png b/textures/mobs_horseshoe_meseo.png new file mode 100644 index 0000000000000000000000000000000000000000..507e8ceeb3f74ff4bf4849e6afef8ee2542e9118 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR?Qg4BfNMxL`x{R-g!D zNswPKgTu2MX+VyUr;B5V#O36K1#%Pq*Eb~YU}Wg(V7$NOR>UEoEQ6=3pUXO@geCx$ C${&sZ literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_steelo.png b/textures/mobs_horseshoe_steelo.png new file mode 100644 index 0000000000000000000000000000000000000000..7a48396890ff5bf639f65016c1252b3ca57b6afe GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR@tcLoZ&um|-&I3s8iy zB*-tA!Qt7BG$2RF)5S4F;&O7r0=WtQ>l+exFfw#?Fy7yCE8-APmci52&t;ucLK6Uc CL?1K& literal 0 HcmV?d00001 From 5414d09a9b11191595710397ea6aaadb46134b2c Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 27 Mar 2020 22:21:15 +0000 Subject: [PATCH 2/5] right click horse to apply horseshoes --- init.lua | 113 +++++++++++++++++++++++++----------------------------- readme.md | 2 +- 2 files changed, 53 insertions(+), 62 deletions(-) diff --git a/init.lua b/init.lua index 370ba53..af0c27d 100644 --- a/init.lua +++ b/init.lua @@ -10,6 +10,14 @@ if minetest.registered_nodes["default:permafrost"] then y_off = 10 end +-- horse shoes (speed, jump, break, overlay texture) +local shoes = { + ["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"}, + ["mobs:horseshoe_bronze"] = {7, 4, 4, "mobs_horseshoe_bronzeo.png"}, + ["mobs:horseshoe_mese"] = {9, 5, 8, "mobs_horseshoe_meseo.png"}, + ["mobs:horseshoe_diamond"] = {10, 6, 6, "mobs_horseshoe_diamondo.png"} +} + -- rideable horse @@ -117,6 +125,8 @@ mobs:register_mob("mob_horse:horse", { if self.tamed and self.owner == clicker:get_player_name() then local inv = clicker:get_inventory() + local tool = clicker:get_wielded_item() + local item = tool:get_name() -- detatch player already riding horse if self.driver and clicker == self.driver then @@ -147,11 +157,52 @@ mobs:register_mob("mob_horse:horse", { self.saddle = true end + + -- apply horseshoes + if item:find("mobs:horseshoe") then + + -- drop any existing shoes + if self.shoed then + minetest.add_item(self.object:get_pos(), self.shoed) + end + + local speed = shoes[item][1] + local jump = shoes[item][2] + local reverse = shoes[item][3] + local overlay = shoes[item][4] + + self.max_speed_forward = speed + self.jump_height = jump + self.max_speed_reverse = reverse + self.accel = speed + self.shoed = item + + -- apply horseshoe overlay to current horse texture + if overlay then + + local ov = self.base_texture + + ov[1] = ov[1] .. "^" .. overlay + + self.object:set_properties({textures = ov}) + end + + -- show horse speed and jump stats with shoes fitted + minetest.chat_send_player(clicker:get_player_name(), + S("Horse shoes fitted -") + .. S(" speed: ") .. speed + .. S(" , jump height: ") .. jump + .. S(" , stop speed: ") .. reverse) + + tool:take_item() ; clicker:set_wielded_item(tool) + + return + end end -- used to capture horse with magic lasso mobs:capture_mob(self, clicker, 0, 0, 80, false, nil) - end + end, }) mobs:spawn({ @@ -168,58 +219,10 @@ mobs:spawn({ mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1) --- horseshoe helper function -local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, - reverse, overlay) - - if obj.type ~= "object" then return end - - local mob = obj.ref - local ent = mob:get_luaentity() - - if ent and ent.name and ent.name == "mob_horse:horse" then - - if ent.shoed then - minetest.add_item(mob:get_pos(), ent.shoed) - end - - ent.max_speed_forward = speed - ent.jump_height = jump - ent.max_speed_reverse = reverse - ent.accel = speed - 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 -") - .. S(" speed: ") .. speed - .. S(" , jump height: ") .. jump - .. S(" , stop speed: ") .. reverse) - - itemstack:take_item() ; return itemstack - else - minetest.chat_send_player(name, S("Horse shoes only work on horses!")) - end -end - - -- steel horseshoes minetest.register_craftitem(":mobs:horseshoe_steel", { description = S("Steel HorseShoes (use on horse to apply)"), inventory_image = "mobs_horseshoe_steel.png", - on_use = function(itemstack, user, pointed_thing) - return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_steel", 7, 4, 2, "mobs_horseshoe_steelo.png") - end, }) minetest.register_craft({ @@ -235,10 +238,6 @@ minetest.register_craft({ minetest.register_craftitem(":mobs:horseshoe_bronze", { description = S("Bronze HorseShoes (use on horse to apply)"), inventory_image = "mobs_horseshoe_bronze.png", - on_use = function(itemstack, user, pointed_thing) - return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_bronze", 7, 4, 4, "mobs_horseshoe_bronzeo.png") - end, }) minetest.register_craft({ @@ -254,10 +253,6 @@ minetest.register_craft({ minetest.register_craftitem(":mobs:horseshoe_mese", { description = S("Mese HorseShoes (use on horse to apply)"), inventory_image = "mobs_horseshoe_mese.png", - on_use = function(itemstack, user, pointed_thing) - return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_mese", 9, 5, 8, "mobs_horseshoe_meseo.png") - end, }) minetest.register_craft({ @@ -273,10 +268,6 @@ minetest.register_craft({ minetest.register_craftitem(":mobs:horseshoe_diamond", { description = S("Diamond HorseShoes (use on horse to apply)"), inventory_image = "mobs_horseshoe_diamond.png", - on_use = function(itemstack, user, pointed_thing) - return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_diamond", 10, 6, 6, "mobs_horseshoe_diamondo.png") - end, }) minetest.register_craft({ diff --git a/readme.md b/readme.md index 952bc2e..3daf23a 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ Horses can be tamed with 10x wheat or apples which then allows the player to pic --- ### Horseshoes -Horseshoes can be crafted using steel, bronze, mese and diamond (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by punching with the item. These can make horses run faster or jump higher depending on tier. +Horseshoes can be crafted using steel, bronze, mese and diamond (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier. --- ### Dead Horse From a49f766a5f532f46c6ebc7dce409c821a5115cf7 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 1 May 2020 08:26:45 +0100 Subject: [PATCH 3/5] horses can now eat wheat, barley, oats, corn and apples --- init.lua | 4 +++- readme.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index af0c27d..dbff24f 100644 --- a/init.lua +++ b/init.lua @@ -47,7 +47,9 @@ mobs:register_mob("mob_horse:horse", { fly = false, walk_chance = 60, view_range = 5, - follow = {"farming:wheat", "default:apple"}, + follow = { + "farming:wheat", "default:apple", "farming:oat", + "farming:barley", "farming:corn"}, passive = true, hp_min = 12, hp_max = 16, diff --git a/readme.md b/readme.md index 3daf23a..5056823 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,7 @@ There are three different horse textures (white, brown, black) which will spawn --- ### Taming -Horses can be tamed with 10x wheat or apples which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle. +Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle. --- ### Horseshoes From e6fbb585ad06343ade683057018a354c17dd4e1b Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 11 May 2020 15:36:53 +0100 Subject: [PATCH 4/5] Added italian locale thanks to Hamlet --- locale/it_IT.po | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 locale/it_IT.po diff --git a/locale/it_IT.po b/locale/it_IT.po new file mode 100644 index 0000000..2b77850 --- /dev/null +++ b/locale/it_IT.po @@ -0,0 +1,59 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-06 00:07+0800\n" +"PO-Revision-Date: 2020-05-11 13:43+0200\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.2.1\n" +"Last-Translator: Hamlet \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: it_IT\n" + +#: init.lua +msgid "Horse" +msgstr "Cavallo" + +#: init.lua +msgid "Horse shoes fitted -" +msgstr "Ferri di cavallo indossati -" + +#: init.lua +msgid " speed: " +msgstr " velocità: " + +#: init.lua +msgid " , jump height: " +msgstr " , altezza di salto: " + +#: init.lua +msgid " , stop speed: " +msgstr " , velocità di arresto: " + +#: init.lua +msgid "Horse shoes only work on horses!" +msgstr "I ferri di cavallo funzionano solo sui cavalli!" + +#: init.lua +msgid "Steel HorseShoes (use on horse to apply)" +msgstr "Ferri di cavallo d'acciaio (usarli su un cavallo per applicarli)" + +#: init.lua +msgid "Bronze HorseShoes (use on horse to apply)" +msgstr "Ferri di cavallo di bronzo (usarli su un cavallo per applicarli)" + +#: init.lua +msgid "Mese HorseShoes (use on horse to apply)" +msgstr "Ferri di cavallo di mese (usarli su un cavallo per applicarli)" + +#: init.lua +msgid "Diamond HorseShoes (use on horse to apply)" +msgstr "Ferri di cavallo di diamante (usarli su un cavallo per applicarli)" From d32cc582c6ac60ace70d4192113c49b6c3e7c961 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sat, 16 May 2020 14:43:45 +0100 Subject: [PATCH 5/5] use 'texture_mods' to overlay horseshoes --- init.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index dbff24f..88d6277 100644 --- a/init.lua +++ b/init.lua @@ -181,12 +181,8 @@ mobs:register_mob("mob_horse:horse", { -- apply horseshoe overlay to current horse texture if overlay then - - local ov = self.base_texture - - ov[1] = ov[1] .. "^" .. overlay - - self.object:set_properties({textures = ov}) + self.texture_mods = "^" .. overlay + self.object:set_texture_mod(self.texture_mods) end -- show horse speed and jump stats with shoes fitted