From c0bfe2a65a2dc37a0a5492252d7811139e03eeb0 Mon Sep 17 00:00:00 2001 From: npx Date: Sun, 25 Sep 2016 11:53:41 +0200 Subject: [PATCH] Added compatibility of nssm_armors to morlu attack --- mobs/morlu.lua | 28 +++++++++++++++++++++------- nssm_armor.lua | 26 +++++++++++++------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/mobs/morlu.lua b/mobs/morlu.lua index c00d6e5..29f922c 100644 --- a/mobs/morlu.lua +++ b/mobs/morlu.lua @@ -91,6 +91,7 @@ mobs:register_mob("nssm:morlu", { else local armor_elements = {} local armor_num = 0 + local steal_pos for i=1,6 do local armor_stack = player_inv:get_stack("armor", i) @@ -101,16 +102,29 @@ mobs:register_mob("nssm:morlu", { end end if armor_num > 0 then + minetest.chat_send_all("Numero di pezzi: "..armor_num) steal_pos = math.random(1,armor_num) steal_pos = steal_pos-1 + for i=0,armor_num-1 do + minetest.chat_send_all("Posizione: "..armor_elements[i].pos.." Oggetto: "..armor_elements[i].name) + end - --minetest.chat_send_all("Stringa -> "..armor_elements[steal_pos].name) + minetest.chat_send_all("Selezionato: pos: "..armor_elements[steal_pos].pos.." nome: "..armor_elements[steal_pos].name) local cpos = string.find(armor_elements[steal_pos].name, ":") --minetest.chat_send_all("Posizione dei due punti: "..cpos) + local mod_name = string.sub(armor_elements[steal_pos].name, 0, cpos-1) local nname = string.sub(armor_elements[steal_pos].name, cpos+1) - nname = "3d_armor_inv_"..nname..".png" - --minetest.chat_send_all("Nuovo nome: "..nname) + --minetest.chat_send_all("Armor Mod name: "..mod_name) + + if mod_name == "3d_armor" then + nname = "3d_armor_inv_"..nname..".png" + elseif mod_name == "nssm" then + nname = "inv_"..nname..".png" + else + nname = "3d_armor_inv_chestplate_diamond.png" + end + --minetest.chat_send_all("Nome della texture: "..nname) minetest.add_particlespawner( 1, --amount @@ -142,10 +156,7 @@ mobs:register_mob("nssm:morlu", { armor:set_player_armor(self.attack, self.attack) --armor:update_armor(self.attack) armor:update_inventory(self.attack) - armor:update_player_visuals(self.attack) - - - + --armor:update_player_visuals(self.attack) set_animation(self, "run") self.flag = 1 @@ -158,6 +169,9 @@ mobs:register_mob("nssm:morlu", { set_velocity(self, 4) end,self) + else + --Aggiungere qui cosa fa se non indossi armatura + end end end diff --git a/nssm_armor.lua b/nssm_armor.lua index 178e7b0..89d50f6 100644 --- a/nssm_armor.lua +++ b/nssm_armor.lua @@ -12,7 +12,7 @@ if minetest.get_modpath("3d_armor") then duck = {name="Duck", armor=1, heal=0, use=10}, black_duck = {name="Black Duck", armor=1, heal=0, use=10}, } - local mats = { + local materials = { wolf="nssm:wolf_fur", whitewolf="nssm:white_wolf_fur", bloco="nssm:bloco_skin", @@ -24,7 +24,7 @@ if minetest.get_modpath("3d_armor") then duck="nssm:duck_feather", black_duck="nssm:black_duck_feather", } - + for k, v in pairs(stats) do minetest.register_tool("nssm:helmet_"..k, { description = v.name.." Helmet", @@ -51,8 +51,8 @@ if minetest.get_modpath("3d_armor") then wear = 0, }) end - - for k, v in pairs(mats) do + + for k, v in pairs(materials) do minetest.register_craft({ output = "nssm:helmet_"..k, recipe = { @@ -91,7 +91,7 @@ if minetest.get_modpath("3d_armor") then crab = {name="Crab", armor=1, heal=0, use=10}, ice ={name="Ice Teeth", armor=1, heal=0, use=10} } - local mats = { + local materials = { crab="nssm:crab_carapace_fragment", ice="nssm:little_ice_tooth", } @@ -102,8 +102,8 @@ if minetest.get_modpath("3d_armor") then groups = {armor_head=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, wear = 0, }) - - local m = mats[k] + + local m = materials[k] minetest.register_craft({ output = "nssm:shield_"..k, recipe = { @@ -127,7 +127,7 @@ local stats = { masticone_crowned ={name="Masticone Crowned Head", armor=1, heal=0, use=10}, snake ={name="", armor=1, heal=0, use=10}, } - --[[local mats = { + --[[local materials = { crab="nssm:crab_carapace_fragment", ice="nssm:little_ice_tooth", }]] @@ -138,7 +138,7 @@ local stats = { groups = {armor_shield=math.floor(5*v.armor), armor_heal=v.heal, armor_use=v.use}, wear = 0, }) - + minetest.register_tool("nssm:chestplate_snake", { description = "Snake Scute Chestplate", inventory_image ="inv_chestplate_snake.png", @@ -146,9 +146,9 @@ local stats = { wear = 0, }) end - - - + + + minetest.register_craft({ output = "nssm:chestplate_snake", recipe = { @@ -174,4 +174,4 @@ local stats = { }, }) -end \ No newline at end of file +end