From c373c972b34ee21017bc327b0b0b6456a64fd7d6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 8 Aug 2020 09:28:47 +0200 Subject: [PATCH 1/5] Fix typo in mcl_brewing: comination --- mods/ITEMS/mcl_brewing/init.lua | 2 +- mods/ITEMS/mcl_brewing/locale/mcl_brewing.de.tr | 2 +- mods/ITEMS/mcl_brewing/locale/mcl_brewing.ru.tr | 2 +- mods/ITEMS/mcl_brewing/locale/template.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index 848c2e9b86..880fb949f3 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -313,7 +313,7 @@ local doc_string = S("To use a brewing stand, rightclick it.").."\n".. S("To brew, you need blaze powder as fuel, a brewing material and at least 1 glass bottle filled with a liquid.").."\n".. S("Place the blaze powder in the left slot, the brewing material in the middle slot and 1-3 bottles in the remaining slots.").."\n".. - S("When you have found a good comination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.").."\n".. + S("When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.").."\n".. S("Different combinations of brewing materials and liquids will give different results. Try to experiment!") local tiles = {"mcl_brewing_top.png", --top diff --git a/mods/ITEMS/mcl_brewing/locale/mcl_brewing.de.tr b/mods/ITEMS/mcl_brewing/locale/mcl_brewing.de.tr index 69aa23c189..fb127c914d 100644 --- a/mods/ITEMS/mcl_brewing/locale/mcl_brewing.de.tr +++ b/mods/ITEMS/mcl_brewing/locale/mcl_brewing.de.tr @@ -4,7 +4,7 @@ Inventory=Inventar To use a brewing stand, rightclick it.=Um einen Braustand zu benutzen, rechtsklicken Sie ihn. To brew, you need blaze powder as fuel, a brewing material and at least 1 glass bottle filled with a liquid.=Zum Brauen benötigt man Lohenstaub als Brennstoff, ein Braumaterial und mindestens 1 Glasflasche, die mit einer Flüssigkeit gefüllt ist. Place the blaze powder in the left slot, the brewing material in the middle slot and 1-3 bottles in the remaining slots.=Platzieren Sie den Lohenstaub in den linken Plartz, das Braumaterial in den mittleren Platz und 1-3 Glasflaschen in die übrigen Plätze. -When you have found a good comination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.=Wenn Sie eine gute Kombination gefunden haben, beginnt der Brauvorgang automatisch, und es entsteht Dampf. Der Brennstoff und das Brühmaterial wird aufbraucht. Die Tränke werden bald fertig sein. +When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.=Wenn Sie eine gute Kombination gefunden haben, beginnt der Brauvorgang automatisch, und es entsteht Dampf. Der Brennstoff und das Brühmaterial wird aufbraucht. Die Tränke werden bald fertig sein. Different combinations of brewing materials and liquids will give different results. Try to experiment!=Unterschiedliche Kombinationen von Braumaterialien und Flüssigkeiten werden zu unterschiedlichen Ergebnissen führen. Experimentieren Sie! The stand allows you to brew potions!=Der Stand ermöglicht das Brauen von Tränken. Brew Potions=Tränke brauen diff --git a/mods/ITEMS/mcl_brewing/locale/mcl_brewing.ru.tr b/mods/ITEMS/mcl_brewing/locale/mcl_brewing.ru.tr index 1cfcfb6310..37b96819d9 100644 --- a/mods/ITEMS/mcl_brewing/locale/mcl_brewing.ru.tr +++ b/mods/ITEMS/mcl_brewing/locale/mcl_brewing.ru.tr @@ -4,7 +4,7 @@ Inventory=Инвентарь To use a brewing stand, rightclick it.=Кликните правой, чтобы использовать варочный стенд. To brew, you need blaze powder as fuel, a brewing material and at least 1 glass bottle filled with a liquid.=Для приготовления зелья вам понадобится огненный порошок в качестве топлива, исходный материал и как минимум 1 стеклянная бутылка, наполненная жидкостью. Place the blaze powder in the left slot, the brewing material in the middle slot and 1-3 bottles in the remaining slots.=Поместите огненный порошок в левый отсек, исходный материал в средний отсек и 1-3 бутылки в оставшиеся отсеки. -When you have found a good comination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.=Когда вы подберёте хорошее сочетание, приготовление зелья начнётся автоматически — появится пар и начнётся расход топлива и исходного материала. Зелья вскоре будут готовы. +When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.=Когда вы подберёте хорошее сочетание, приготовление зелья начнётся автоматически — появится пар и начнётся расход топлива и исходного материала. Зелья вскоре будут готовы. Different combinations of brewing materials and liquids will give different results. Try to experiment!=Разные сочетания варочных материалов и жидкостей будут давать разные результаты. Поэкспериментируйте! The stand allows you to brew potions!=Стенд позволяет вам варить зелья! Brew Potions=Зельеварение diff --git a/mods/ITEMS/mcl_brewing/locale/template.txt b/mods/ITEMS/mcl_brewing/locale/template.txt index 1727881562..e5619f1e10 100644 --- a/mods/ITEMS/mcl_brewing/locale/template.txt +++ b/mods/ITEMS/mcl_brewing/locale/template.txt @@ -4,7 +4,7 @@ Inventory= To use a brewing stand, rightclick it.= To brew, you need blaze powder as fuel, a brewing material and at least 1 glass bottle filled with a liquid.= Place the blaze powder in the left slot, the brewing material in the middle slot and 1-3 bottles in the remaining slots.= -When you have found a good comination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.= +When you have found a good combination, the brewing will commence automatically and steam starts to appear, using up the fuel and brewing material. The potions will soon be ready.= Different combinations of brewing materials and liquids will give different results. Try to experiment!= The stand allows you to brew potions!= Brew Potions= From 7104bbd2dfd2d3a1aef0d65fd36aa75dd5757b73 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 8 Aug 2020 09:32:38 +0200 Subject: [PATCH 2/5] Remove tt strings for WIP potions for now --- mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr | 5 ----- mods/ITEMS/mcl_potions/locale/mcl_potions.es.tr | 5 ----- mods/ITEMS/mcl_potions/locale/mcl_potions.fr.tr | 5 ----- mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr | 5 ----- mods/ITEMS/mcl_potions/locale/template.txt | 5 ----- mods/ITEMS/mcl_potions/potions.lua | 10 +++++----- 6 files changed, 5 insertions(+), 30 deletions(-) diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr index c20a61d1fe..68ce919d6f 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.de.tr @@ -100,15 +100,10 @@ Grants limitless breath underwater.=Gibt unbegrenzten Atem im Wasser. Fire Resistance=Feuerresistenz Grants immunity to damage from heat sources like fire.=Gibt Immunität gegenüber Schaden von Hitzequellen wie Feuer. Weakness=Schwäche --4 HP damage | 1:30=-4 HP Schaden | 1:30 Weakness +=Schwäche + --4 HP damage | 4:00=-4 HP Schaden | 4:00 Strength=Stärke -+3 HP damage | 3:00=+3 HP Schaden | 3:00 Strength II=Stärke II -+6 HP damage | 1:30=+6 HP Schaden | 1:30 Strength +=Stärke + -+3 HP damage | 8:00=+3 HP Schaden | 8:00 Try different combinations to create potions.=Probieren Sie Kombinationen aus, um Tränke herzustellen. No effect=Keine Wirkung diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.es.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.es.tr index 9b5bc6a848..5a03a6f9de 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.es.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.es.tr @@ -99,15 +99,10 @@ Grants limitless breath underwater.= Fire Resistance= Grants immunity to damage from heat sources like fire.= Weakness= --4 HP damage | 1:30= Weakness += --4 HP damage | 4:00= Strength= -+3 HP damage | 3:00= Strength II= -+6 HP damage | 1:30= Strength += -+3 HP damage | 8:00= Try different combinations to create potions.= No effect= diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.fr.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.fr.tr index ce149320d8..d1ea0f9a6c 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.fr.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.fr.tr @@ -99,15 +99,10 @@ Grants limitless breath underwater.= Fire Resistance= Grants immunity to damage from heat sources like fire.= Weakness= --4 HP damage | 1:30= Weakness += --4 HP damage | 4:00= Strength= -+3 HP damage | 3:00= Strength II= -+6 HP damage | 1:30= Strength += -+3 HP damage | 8:00= Try different combinations to create potions.= No effect=Aucun effet diff --git a/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr b/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr index af8a34f3b0..150d5e3964 100644 --- a/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr +++ b/mods/ITEMS/mcl_potions/locale/mcl_potions.ru.tr @@ -99,15 +99,10 @@ Grants limitless breath underwater.=Даёт возможность неогра Fire Resistance=Огнестойкость Grants immunity to damage from heat sources like fire.=Делает невосприимчивым к урону от источников тепла, например, от огня. Weakness=Слабость --4 HP damage | 1:30=Урон -4 HP | 1:30 Weakness +=Слабость + --4 HP damage | 4:00=Урон -4 HP | 4:00 Strength=Сила -+3 HP damage | 3:00=Урон +3 HP | 3:00 Strength II=Сила II -+6 HP damage | 1:30=Урон +6 HP | 1:30 Strength +=Сила + -+3 HP damage | 8:00=Урон +3 HP | 8:00 Try different combinations to create potions.=Пробуйте разные сочетания для приготовления зелий. No effect=Не оказывает эффекта diff --git a/mods/ITEMS/mcl_potions/locale/template.txt b/mods/ITEMS/mcl_potions/locale/template.txt index 28797e6593..99f48a01fc 100644 --- a/mods/ITEMS/mcl_potions/locale/template.txt +++ b/mods/ITEMS/mcl_potions/locale/template.txt @@ -99,15 +99,10 @@ Grants limitless breath underwater.= Fire Resistance= Grants immunity to damage from heat sources like fire.= Weakness= --4 HP damage | 1:30= Weakness += --4 HP damage | 4:00= Strength= -+3 HP damage | 3:00= Strength II= -+6 HP damage | 1:30= Strength += -+3 HP damage | 8:00= Try different combinations to create potions.= No effect= diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index b7608bd8c4..4664cec5c0 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -578,7 +578,7 @@ end -- minetest.register_craftitem("mcl_potions:weakness", { -- description = S("Weakness"), --- _tt_help = S("-4 HP damage | 1:30"), +-- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#6600AA"), -- inventory_image = potion_image("#6600AA"), @@ -602,7 +602,7 @@ end -- -- minetest.register_craftitem("mcl_potions:weakness_plus", { -- description = S("Weakness +"), --- _tt_help = S("-4 HP damage | 4:00"), +-- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#7700BB"), -- inventory_image = potion_image("#7700BB"), @@ -626,7 +626,7 @@ end -- -- minetest.register_craftitem("mcl_potions:strength", { -- description = S("Strength"), --- _tt_help = S("+3 HP damage | 3:00"), +-- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444D4"), -- inventory_image = potion_image("#D444D4"), @@ -650,7 +650,7 @@ end -- -- minetest.register_craftitem("mcl_potions:strength_2", { -- description = S("Strength II"), --- _tt_help = S("+6 HP damage | 1:30"), +-- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444E4"), -- inventory_image = potion_image("#D444E4"), @@ -674,7 +674,7 @@ end -- -- minetest.register_craftitem("mcl_potions:strength_plus", { -- description = S("Strength +"), --- _tt_help = S("+3 HP damage | 8:00"), +-- _tt_help = TODO, -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444F4"), -- inventory_image = potion_image("#D444F4"), From a472c30163889aae5994402a73accb79ffb7cefa Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 8 Aug 2020 10:00:16 +0200 Subject: [PATCH 3/5] Fix indentations in mcl_potions/mcl_brewing --- mods/ITEMS/mcl_brewing/init.lua | 44 +++--- mods/ITEMS/mcl_potions/functions.lua | 111 ++++++++------- mods/ITEMS/mcl_potions/init.lua | 34 ++--- mods/ITEMS/mcl_potions/lingering.lua | 176 ++++++++++++------------ mods/ITEMS/mcl_potions/potions.lua | 46 ++++--- mods/ITEMS/mcl_potions/splash.lua | 147 ++++++++++---------- mods/ITEMS/mcl_potions/tipped_arrow.lua | 11 +- 7 files changed, 294 insertions(+), 275 deletions(-) diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index 880fb949f3..944b32aa31 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -152,22 +152,22 @@ local function brewing_stand_timer(pos, elapsed) d = 0.5 minetest.add_particlespawner({ - amount = 4, - time = 1, - minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, - minvel = {x=-0.1, y=0, z=-0.1}, - maxvel = {x=0.1, y=0.5, z=0.1}, - minacc = {x=-0.05, y=0, z=-0.05}, - maxacc = {x=0.05, y=.1, z=0.05}, - minexptime = 1, - maxexptime = 2, - minsize = 0.5, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = "mcl_brewing_bubble_sprite.png", - }) + amount = 4, + time = 1, + minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, + minvel = {x=-0.1, y=0, z=-0.1}, + maxvel = {x=0.1, y=0.5, z=0.1}, + minacc = {x=-0.05, y=0, z=-0.05}, + maxacc = {x=0.05, y=.1, z=0.05}, + minexptime = 1, + maxexptime = 2, + minsize = 0.5, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = "mcl_brewing_bubble_sprite.png", + }) -- Replace the stand item with the brew result if stand_timer >= BREW_TIME then @@ -231,7 +231,6 @@ local function brewing_stand_timer(pos, elapsed) meta:set_float("fuel_timer", fuel_timer) meta:set_float("stand_timer", stand_timer) meta:set_float("fuel", fuel) - -- meta:set_list("stand_items", stand_list) meta:set_string("formspec", formspec) return result @@ -317,11 +316,11 @@ local doc_string = S("Different combinations of brewing materials and liquids will give different results. Try to experiment!") local tiles = {"mcl_brewing_top.png", --top - "mcl_brewing_base.png", --bottom - "mcl_brewing_side.png", --right - "mcl_brewing_side.png", --left - "mcl_brewing_side.png", --back - "mcl_brewing_side.png^[transformFX"} --front + "mcl_brewing_base.png", --bottom + "mcl_brewing_side.png", --right + "mcl_brewing_side.png", --left + "mcl_brewing_side.png", --back + "mcl_brewing_side.png^[transformFX"} --front local allow_put = function(pos, listname, index, stack, player) local name = player:get_player_name() @@ -856,7 +855,6 @@ minetest.register_node("mcl_brewing:stand_011", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 539727b591..ad1cc9c55e 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -296,14 +296,15 @@ minetest.register_globalstep(function(dtime) end) -local is_fire_node = { ["mcl_core:lava_flowing"]=true, - ["mcl_core:lava_source"]=true, - ["mcl_fire:eternal_fire"]=true, - ["mcl_fire:fire"]=true, - ["mcl_nether:magma"]=true, - ["mcl_nether:nether_lava_source"]=true, - ["mcl_nether:nether_lava_flowing"]=true, - ["mcl_nether:nether_lava_source"]=true} +local is_fire_node = { ["mcl_core:lava_flowing"]=true, + ["mcl_core:lava_source"]=true, + ["mcl_fire:eternal_fire"]=true, + ["mcl_fire:fire"]=true, + ["mcl_nether:magma"]=true, + ["mcl_nether:nether_lava_source"]=true, + ["mcl_nether:nether_lava_flowing"]=true, + ["mcl_nether:nether_lava_source"]=true +} -- Prevent damage to player with Fire Resistance enabled minetest.register_on_player_hpchange(function(player, hp_change, reason) @@ -314,8 +315,6 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason) -- it's worth noting that you don't take damage from players in this case... local player_info = mcl_playerinfo[player:get_player_name()] - -- if reason.type == "drown" then return hp_change - if is_fire_node[player_info.node_head] or is_fire_node[player_info.node_feet] or is_fire_node[player_info.node_stand] then return 0 else @@ -347,7 +346,9 @@ end, true) function mcl_potions._reset_player_effects(player) - if not player:is_player() then return end + if not player:is_player() then + return + end meta = player:get_meta() mcl_potions.make_invisible(player, false) @@ -375,7 +376,9 @@ end function mcl_potions._save_player_effects(player) - if not player:is_player() then return end + if not player:is_player() then + return + end meta = player:get_meta() meta:set_string("_is_invisible", minetest.serialize(is_invisible[player])) @@ -393,7 +396,9 @@ end function mcl_potions._load_player_effects(player) - if not player:is_player() then return end + if not player:is_player() then + return + end meta = player:get_meta() if minetest.deserialize(meta:get_string("_is_invisible")) then @@ -487,7 +492,9 @@ function mcl_potions.is_obj_hit(self, pos) if entity and entity.name ~= self.object:get_luaentity().name then - if entity._cmi_is_mob then return true end + if entity._cmi_is_mob then + return true + end elseif object:is_player() and self._thrower ~= object:get_player_name() then return true @@ -500,7 +507,9 @@ end function mcl_potions.make_invisible(player, toggle) - if not player then return false end + if not player then + return false + end local is_player = player:is_player() local entity = player:get_luaentity() @@ -533,22 +542,22 @@ function mcl_potions._use_potion(item, obj, color) local pos = obj:get_pos() minetest.sound_play("mcl_potions_drinking", {pos = pos, max_hear_distance = 6, gain = 1}) minetest.add_particlespawner({ - amount = 25, - time = 1, - minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, - minvel = {x=-0.1, y=0, z=-0.1}, - maxvel = {x=0.1, y=0.1, z=0.1}, - minacc = {x=-0.1, y=0, z=-0.1}, - maxacc = {x=0.1, y=.1, z=0.1}, - minexptime = 1, - maxexptime = 5, - minsize = 0.5, - maxsize = 1, - collisiondetection = true, - vertical = false, - texture = "mcl_potions_sprite.png^[colorize:"..color..":127", - }) + amount = 25, + time = 1, + minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, + minvel = {x=-0.1, y=0, z=-0.1}, + maxvel = {x=0.1, y=0.1, z=0.1}, + minacc = {x=-0.1, y=0, z=-0.1}, + maxacc = {x=0.1, y=.1, z=0.1}, + minexptime = 1, + maxexptime = 5, + minsize = 0.5, + maxsize = 1, + collisiondetection = true, + vertical = false, + texture = "mcl_potions_sprite.png^[colorize:"..color..":127", + }) end @@ -556,22 +565,22 @@ function mcl_potions._add_spawner(obj, color) local d = 0.2 local pos = obj:get_pos() minetest.add_particlespawner({ - amount = 1, - time = 1, - minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, - minvel = {x=-0.1, y=0, z=-0.1}, - maxvel = {x=0.1, y=0.1, z=0.1}, - minacc = {x=-0.1, y=0, z=-0.1}, - maxacc = {x=0.1, y=.1, z=0.1}, - minexptime = 0.5, - maxexptime = 1, - minsize = 0.5, - maxsize = 1, - collisiondetection = false, - vertical = false, - texture = "mcl_potions_sprite.png^[colorize:"..color..":127", - }) + amount = 1, + time = 1, + minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d}, + minvel = {x=-0.1, y=0, z=-0.1}, + maxvel = {x=0.1, y=0.1, z=0.1}, + minacc = {x=-0.1, y=0, z=-0.1}, + maxacc = {x=0.1, y=.1, z=0.1}, + minexptime = 0.5, + maxexptime = 1, + minsize = 0.5, + maxsize = 1, + collisiondetection = false, + vertical = false, + texture = "mcl_potions_sprite.png^[colorize:"..color..":127", + }) end @@ -633,7 +642,9 @@ end function mcl_potions.swiftness_func(player, factor, duration) - if not player:get_meta() then return false end + if not player:get_meta() then + return false + end if not is_swift[player] then @@ -654,7 +665,9 @@ end function mcl_potions.leaping_func(player, factor, duration) - if not player:get_meta() then return false end + if not player:get_meta() then + return false + end if not is_leaping[player] then diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 045664b632..a712005e7e 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -296,14 +296,14 @@ end mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", { tt=S("Extinguishes fire and hurts some mobs"), - longdesc=S("A throwable water bottle that will shatter on impact, where it extinguishes nearby fire and hurts mobs that are vulnerable to water."), + longdesc=S("A throwable water bottle that will shatter on impact, where it extinguishes nearby fire and hurts mobs that are vulnerable to water."), no_effect=true, potion_fun=water_splash, effect=1 }) mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", { tt=S("Extinguishes fire and hurts some mobs"), - longdesc=S("A throwable water bottle that will shatter on impact, where it creates a cloud of water vapor that lingers on the ground for a while. This cloud extinguishes fire and hurts mobs that are vulnerable to water."), + longdesc=S("A throwable water bottle that will shatter on impact, where it creates a cloud of water vapor that lingers on the ground for a while. This cloud extinguishes fire and hurts mobs that are vulnerable to water."), no_effect=true, potion_fun=water_splash, effect=1 @@ -366,23 +366,23 @@ local extension_table = {} local potions = {} for i, potion in ipairs({"healing","harming","swiftness","slowness", - "leaping","poison","regeneration","invisibility","fire_resistance", - -- "weakness","strength", - "water_breathing","night_vision"}) do + "leaping","poison","regeneration","invisibility","fire_resistance", + -- "weakness","strength", + "water_breathing","night_vision"}) do - table.insert(potions, potion) + table.insert(potions, potion) - if potion ~= "invisibility" and potion ~= "night_vision" and potion ~= "weakness" and potion ~= "water_breathing" and potion ~= "fire_resistance" then - enhancement_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_2" - enhancement_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_2_splash" - table.insert(potions, potion.."_2") - end + if potion ~= "invisibility" and potion ~= "night_vision" and potion ~= "weakness" and potion ~= "water_breathing" and potion ~= "fire_resistance" then + enhancement_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_2" + enhancement_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_2_splash" + table.insert(potions, potion.."_2") + end - if potion ~= "healing" and potion ~= "harming" then - extension_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_plus_splash" - extension_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_plus" - table.insert(potions, potion.."_plus") - end + if potion ~= "healing" and potion ~= "harming" then + extension_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_plus_splash" + extension_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_plus" + table.insert(potions, potion.."_plus") + end end @@ -419,7 +419,7 @@ local splash_table = {} local lingering_table = {} for i, potion in ipairs(potions) do - splash_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_splash" + splash_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_splash" lingering_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_lingering" end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 57141ea89c..c74143233e 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -71,7 +71,9 @@ minetest.register_globalstep(function(dtime) end end - if vals.timer <= 0 then lingering_effect_at[pos] = nil end + if vals.timer <= 0 then + lingering_effect_at[pos] = nil + end end lingering_timer = 0 @@ -82,93 +84,93 @@ end) function mcl_potions.register_lingering(name, descr, color, def) - local id = "mcl_potions:"..name.."_lingering" - local longdesc = def.longdesc - if not def.no_effect then - longdesc = S("A throwable potion that will shatter on impact, where it creates a magic cloud that lingers around for a while. Any player or mob inside the cloud will receive the potion's effect, possibly repeatedly.") - if def.longdesc then - longdesc = longdesc .. "\n" .. def.longdesc - end - end - minetest.register_craftitem(id, { - description = descr, - _tt_help = def.tt, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = S("Use the “Punch” key to throw it."), - inventory_image = lingering_image(color), - groups = {brewitem=1, not_in_creative_inventory=0}, - on_use = function(item, placer, pointed_thing) - local velocity = 10 - local dir = placer:get_look_dir(); - local pos = placer:getpos(); - local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") - obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) - obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) - obj:get_luaentity()._thrower = placer:get_player_name() - if not minetest.is_creative_enabled(placer:get_player_name()) then - item:take_item() - end - return item - end, - stack_max = 1, - _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) - local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) - local obj = minetest.add_entity({x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}, id.."_flying") - local velocity = 22 - obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) - obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) + local id = "mcl_potions:"..name.."_lingering" + local longdesc = def.longdesc + if not def.no_effect then + longdesc = S("A throwable potion that will shatter on impact, where it creates a magic cloud that lingers around for a while. Any player or mob inside the cloud will receive the potion's effect, possibly repeatedly.") + if def.longdesc then + longdesc = longdesc .. "\n" .. def.longdesc end - }) + end + minetest.register_craftitem(id, { + description = descr, + _tt_help = def.tt, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = S("Use the “Punch” key to throw it."), + inventory_image = lingering_image(color), + groups = {brewitem=1, not_in_creative_inventory=0}, + on_use = function(item, placer, pointed_thing) + local velocity = 10 + local dir = placer:get_look_dir(); + local pos = placer:getpos(); + local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") + obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) + obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) + obj:get_luaentity()._thrower = placer:get_player_name() + if not minetest.is_creative_enabled(placer:get_player_name()) then + item:take_item() + end + return item + end, + stack_max = 1, + _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) + local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) + local obj = minetest.add_entity({x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}, id.."_flying") + local velocity = 22 + obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) + obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) + end +}) - local w = 0.7 +local w = 0.7 - minetest.register_entity(id.."_flying",{ - textures = {lingering_image(color)}, - hp_max = 1, - visual_size = {x=w/2,y=w/2}, - collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, - pointable = false, - on_step = function(self, dtime) - local pos = self.object:get_pos() - local node = minetest.get_node(pos) - local n = node.name - local g = minetest.get_node_group(n, "liquid") - local d = 4 - if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then - minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) - add_lingering_effect(pos, color, def, name == "water") - local texture, minacc, maxacc - if name == "water" then - texture = "mcl_potions_droplet.png" - minacc = {x=-0.2, y=-0.05, z=-0.2} - maxacc = {x=0.2, y=0.05, z=0.2} - else - texture = "mcl_potions_sprite.png" - minacc = {x=-0.2, y=0, z=-0.2} - maxacc = {x=0.2, y=.05, z=0.2} - end - minetest.add_particlespawner({ - amount = 40, - time = 1, - minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, - minvel = {x=-0.5, y=0, z=-0.5}, - maxvel = {x=0.5, y=0.5, z=0.5}, - minacc = minacc, - maxacc = maxacc, - minexptime = 1, - maxexptime = 2, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = texture.."^[colorize:"..color..":127", - }) - if name == "water" then - mcl_potions._extinguish_nearby_fire(pos, d) - end - self.object:remove() - end - end, - }) +minetest.register_entity(id.."_flying",{ + textures = {lingering_image(color)}, + hp_max = 1, + visual_size = {x=w/2,y=w/2}, + collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, + pointable = false, + on_step = function(self, dtime) + local pos = self.object:get_pos() + local node = minetest.get_node(pos) + local n = node.name + local g = minetest.get_node_group(n, "liquid") + local d = 4 + if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then + minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) + add_lingering_effect(pos, color, def, name == "water") + local texture, minacc, maxacc + if name == "water" then + texture = "mcl_potions_droplet.png" + minacc = {x=-0.2, y=-0.05, z=-0.2} + maxacc = {x=0.2, y=0.05, z=0.2} + else + texture = "mcl_potions_sprite.png" + minacc = {x=-0.2, y=0, z=-0.2} + maxacc = {x=0.2, y=.05, z=0.2} + end + minetest.add_particlespawner({ + amount = 40, + time = 1, + minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, + minvel = {x=-0.5, y=0, z=-0.5}, + maxvel = {x=0.5, y=0.5, z=0.5}, + minacc = minacc, + maxacc = maxacc, + minexptime = 1, + maxexptime = 2, + minsize = 1, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = texture.."^[colorize:"..color..":127", + }) + if name == "water" then + mcl_potions._extinguish_nearby_fire(pos, d) + end + self.object:remove() + end + end, +}) end diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 4664cec5c0..a226ad7190 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -12,7 +12,9 @@ local how_to_drink = S("Use the “Place” key to drink it.") local potion_intro = S("Drinking a potion gives you a particular effect.") local function time_string(dur) - if not dur then return nil end + if not dur then + return nil + end return math.floor(dur/60)..string.format(":%02d",math.floor(dur % 60)) end local function perc_string(num) @@ -55,12 +57,14 @@ local function register_potion(def) end local on_use = function (itemstack, user, pointed_thing) - if not def.on_use then return end - def.on_use(user, def.effect, dur) - minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) - mcl_potions._use_potion(itemstack, user, def.color) - return itemstack - end + if not def.on_use then + return + end + def.on_use(user, def.effect, dur) + minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) + mcl_potions._use_potion(itemstack, user, def.color) + return itemstack + end local function get_tt(tt, effect, dur) local _tt @@ -121,7 +125,7 @@ local function register_potion(def) if not def.no_effect then potion_longdesc = potion_intro .. "\n" .. def._longdesc end - local potion_usagehelp + local potion_usagehelp local basic_potion_tt if def.name ~= "dragon_breath" then potion_usagehelp = how_to_drink @@ -218,11 +222,11 @@ local function register_potion(def) end local on_use = function (itemstack, user, pointed_thing) - def.on_use(user, effect_II, dur_2) - minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) - mcl_potions._use_potion(itemstack, user, def.color) - return itemstack - end + def.on_use(user, effect_II, dur_2) + minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) + mcl_potions._use_potion(itemstack, user, def.color) + return itemstack + end minetest.register_craftitem("mcl_potions:"..def.name.."_2", { description = S("@1 Potion@2", def.description, desc_mod), @@ -301,11 +305,11 @@ local function register_potion(def) end local on_use = function (itemstack, user, pointed_thing) - def.on_use(user, def.effect, dur_pl) - minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) - mcl_potions._use_potion(itemstack, user, def.color) - return itemstack - end + def.on_use(user, def.effect, dur_pl) + minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) + mcl_potions._use_potion(itemstack, user, def.color) + return itemstack + end minetest.register_craftitem("mcl_potions:"..def.name.."_plus", { description = S("@1 + Potion", def.description), @@ -565,9 +569,9 @@ local fire_resistance_def = { local defs = { awkward_def, mundane_def, thick_def, dragon_breath_def, - healing_def, harming_def, night_vision_def, swiftness_def, - slowness_def, leaping_def, poison_def, regeneration_def, - invisibility_def, water_breathing_def, fire_resistance_def} + healing_def, harming_def, night_vision_def, swiftness_def, + slowness_def, leaping_def, poison_def, regeneration_def, + invisibility_def, water_breathing_def, fire_resistance_def} for _, def in ipairs(defs) do register_potion(def) diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 6fd761eea3..2f7fbf77f2 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -11,34 +11,34 @@ end function mcl_potions.register_splash(name, descr, color, def) - local id = "mcl_potions:"..name.."_splash" - local longdesc = def.longdesc - if not def.no_effect then - longdesc = S("A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.") - if def.longdesc then - longdesc = longdesc .. "\n" .. def.longdesc - end - end - minetest.register_craftitem(id, { - description = descr, + local id = "mcl_potions:"..name.."_splash" + local longdesc = def.longdesc + if not def.no_effect then + longdesc = S("A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.") + if def.longdesc then + longdesc = longdesc .. "\n" .. def.longdesc + end + end + minetest.register_craftitem(id, { + description = descr, _tt_help = def.tt, - _doc_items_longdesc = longdesc, - _doc_items_usagehelp = S("Use the “Punch” key to throw it."), - inventory_image = splash_image(color), + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = S("Use the “Punch” key to throw it."), + inventory_image = splash_image(color), groups = {brewitem=1, not_in_creative_inventory=0}, - on_use = function(item, placer, pointed_thing) - local velocity = 10 - local dir = placer:get_look_dir(); - local pos = placer:get_pos(); - local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") - obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) - obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) + on_use = function(item, placer, pointed_thing) + local velocity = 10 + local dir = placer:get_look_dir(); + local pos = placer:get_pos(); + local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") + obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) + obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) obj:get_luaentity()._thrower = placer:get_player_name() if not minetest.is_creative_enabled(placer:get_player_name()) then item:take_item() end - return item - end, + return item + end, stack_max = 1, _on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir) local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51)) @@ -47,70 +47,73 @@ function mcl_potions.register_splash(name, descr, color, def) obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity}) obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3}) end - }) + }) - local w = 0.7 + local w = 0.7 - minetest.register_entity(id.."_flying",{ - textures = {splash_image(color)}, + minetest.register_entity(id.."_flying",{ + textures = {splash_image(color)}, hp_max = 1, visual_size = {x=w/2,y=w/2}, collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, pointable = false, - on_step = function(self, dtime) - local pos = self.object:get_pos() - local node = minetest.get_node(pos) - local n = node.name - local g = minetest.get_node_group(n, "liquid") - local d = 0.1 - local redux_map = {7/8,0.5,0.25} - if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then - minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) - local texture, acc - if name == "water" then - texture = "mcl_potions_droplet.png" - acc = {x=0, y=-GRAVITY, z=0} - else - texture = "mcl_potions_sprite.png" - acc = {x=0, y=0, z=0} - end - minetest.add_particlespawner({ - amount = 50, - time = 0.1, - minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+0.5+d, z=pos.z+d}, - minvel = {x=-2, y=0, z=-2}, - maxvel = {x=2, y=2, z=2}, - minacc = acc, - maxacc = acc, - minexptime = 0.5, - maxexptime = 1.25, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = texture.."^[colorize:"..color..":127" - }) + on_step = function(self, dtime) + local pos = self.object:get_pos() + local node = minetest.get_node(pos) + local n = node.name + local g = minetest.get_node_group(n, "liquid") + local d = 0.1 + local redux_map = {7/8,0.5,0.25} + if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then + minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) + local texture, acc + if name == "water" then + texture = "mcl_potions_droplet.png" + acc = {x=0, y=-GRAVITY, z=0} + else + texture = "mcl_potions_sprite.png" + acc = {x=0, y=0, z=0} + end + minetest.add_particlespawner({ + amount = 50, + time = 0.1, + minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+0.5+d, z=pos.z+d}, + minvel = {x=-2, y=0, z=-2}, + maxvel = {x=2, y=2, z=2}, + minacc = acc, + maxacc = acc, + minexptime = 0.5, + maxexptime = 1.25, + minsize = 1, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = texture.."^[colorize:"..color..":127" + }) if name == "water" then mcl_potions._extinguish_nearby_fire(pos) end - self.object:remove() - for _,obj in pairs(minetest.get_objects_inside_radius(pos, 4)) do + self.object:remove() + for _,obj in pairs(minetest.get_objects_inside_radius(pos, 4)) do - local entity = obj:get_luaentity() - if obj:is_player() or entity._cmi_is_mob then + local entity = obj:get_luaentity() + if obj:is_player() or entity._cmi_is_mob then - local pos2 = obj:get_pos() - local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2)) - if rad > 0 then def.potion_fun(obj, redux_map[rad]) else def.potion_fun(obj, 1) end - - end + local pos2 = obj:get_pos() + local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2)) + if rad > 0 then + def.potion_fun(obj, redux_map[rad]) + else + def.potion_fun(obj, 1) end - end - end, - }) + end + + end + end, + }) end local function time_string(dur) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index f9bfa166e1..31e7c1dddd 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -19,12 +19,11 @@ local function arrow_image(colorstring, opacity) opacity = 127 end return {"mcl_bows_arrow.png^[transformFX^(mcl_bows_arrow_overlay.png^[transformFX^[colorize:"..colorstring..":"..tostring(opacity)..")", - "mcl_bows_arrow.png^[transformFX^(mcl_bows_arrow_overlay.png^[transformFX^[colorize:"..colorstring..":"..tostring(opacity)..")", - "mcl_bows_arrow_back.png^[colorize:"..colorstring..":"..tostring(opacity), - "mcl_bows_arrow_front.png^[colorize:"..colorstring..":"..tostring(opacity), - "mcl_bows_arrow.png^(mcl_bows_arrow_overlay.png^[colorize:"..colorstring..":"..tostring(opacity)..")", - "mcl_bows_arrow.png^[transformFX^(mcl_bows_arrow_overlay.png^[transformFX^[colorize:"..colorstring..":"..tostring(opacity)..")"} - + "mcl_bows_arrow.png^[transformFX^(mcl_bows_arrow_overlay.png^[transformFX^[colorize:"..colorstring..":"..tostring(opacity)..")", + "mcl_bows_arrow_back.png^[colorize:"..colorstring..":"..tostring(opacity), + "mcl_bows_arrow_front.png^[colorize:"..colorstring..":"..tostring(opacity), + "mcl_bows_arrow.png^(mcl_bows_arrow_overlay.png^[colorize:"..colorstring..":"..tostring(opacity)..")", + "mcl_bows_arrow.png^[transformFX^(mcl_bows_arrow_overlay.png^[transformFX^[colorize:"..colorstring..":"..tostring(opacity)..")"} end local how_to_shoot = minetest.registered_items["mcl_bows:arrow"]._doc_items_usagehelp From aaa13878c1d7cbb612497eabe405f0ebb44c04e1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 8 Aug 2020 10:14:37 +0200 Subject: [PATCH 4/5] Clean up the effect test command a little --- mods/ITEMS/mcl_potions/functions.lua | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index ad1cc9c55e..79e9bf9b16 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -1,3 +1,5 @@ +local S = minetest.get_translator("mcl_potions") + local is_invisible = {} local is_poisoned = {} local is_regenerating = {} @@ -902,28 +904,33 @@ get_chat_function["leaping"] = mcl_potions.leaping_func get_chat_function["swiftness"] = mcl_potions.swiftness_func get_chat_function["heal"] = mcl_potions.healing_func -minetest.register_chatcommand("potion",{ - params = "", - description = "Set player potion effects -- arguments ", +minetest.register_chatcommand("effect",{ + params = S(" "), + description = S("Add a status effect to yourself. Arguments: : name of potion effect, e.g. poison. : effect strength multiplier (1 = 100%). : duration in seconds"), privs = {server = true}, func = function(name, params) - P = {} - i = 0 + local P = {} + local i = 0 for str in string.gmatch(params, "([^ ]+)") do i = i + 1 P[i] = str end - if not P[3] then - P[3] = P[2] + if not P[1] then + return false, S("Missing effect parameter!") + elseif not P[2] then + return false, S("Missing factor parameter!") + elseif not P[3] then + return false, S("Missing duration parameter!") end if get_chat_function[P[1]] then get_chat_function[P[1]](minetest.get_player_by_name(name), tonumber(P[2]), tonumber(P[3])) + return true else - minetest.chat_send_player(name, P[1].." is not an available potion effect. Use /help potion as needed.") + return false, S("@1 is not an available potion effect.", P[1]) end - end , + end, }) From db1cc2e0127067007c46ac7d1061afe5d0c577ba Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 8 Aug 2020 10:25:23 +0200 Subject: [PATCH 5/5] Effect command: Swap arguments --- mods/ITEMS/mcl_potions/functions.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 79e9bf9b16..d9233c6d3d 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -905,8 +905,8 @@ get_chat_function["swiftness"] = mcl_potions.swiftness_func get_chat_function["heal"] = mcl_potions.healing_func minetest.register_chatcommand("effect",{ - params = S(" "), - description = S("Add a status effect to yourself. Arguments: : name of potion effect, e.g. poison. : effect strength multiplier (1 = 100%). : duration in seconds"), + params = S(" []"), + description = S("Add a status effect to yourself. Arguments: : name of potion effect, e.g. poison. : duration in seconds. : effect strength multiplier (1 = 100%)"), privs = {server = true}, func = function(name, params) @@ -919,14 +919,18 @@ minetest.register_chatcommand("effect",{ if not P[1] then return false, S("Missing effect parameter!") - elseif not P[2] then - return false, S("Missing factor parameter!") - elseif not P[3] then - return false, S("Missing duration parameter!") + elseif not tonumber(P[2]) then + return false, S("Missing or invalid duration parameter!") + elseif P[3] and not tonumber(P[3]) then + return false, S("Invalid factor parameter!") + end + -- Default factor = 1 + if not P[3] then + P[3] = 1.0 end if get_chat_function[P[1]] then - get_chat_function[P[1]](minetest.get_player_by_name(name), tonumber(P[2]), tonumber(P[3])) + get_chat_function[P[1]](minetest.get_player_by_name(name), tonumber(P[3]), tonumber(P[2])) return true else return false, S("@1 is not an available potion effect.", P[1])