1
0
Fork 0

Add the ability to give use lingering potions to tip arrows.

Corrected issue with bow not finding potion arrows in inventory.
This commit is contained in:
Brandon 2020-07-19 21:08:50 -04:00
parent 0f5b6b7ce0
commit 26315d44cf
3 changed files with 27 additions and 6 deletions

View File

@ -226,7 +226,7 @@ controls.register_on_hold(function(player, key, time)
local inv = minetest.get_inventory({type="player", name=name}) local inv = minetest.get_inventory({type="player", name=name})
local wielditem = player:get_wielded_item() local wielditem = player:get_wielded_item()
local creative = minetest.is_creative_enabled(name) local creative = minetest.is_creative_enabled(name)
if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or inv:contains_item("main", "mcl_bows:arrow")) then if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or #get_arrow(player)) then --inv:contains_item("main", "mcl_bows:arrow")) then
wielditem:set_name("mcl_bows:bow_0") wielditem:set_name("mcl_bows:bow_0")
player:set_wielded_item(wielditem) player:set_wielded_item(wielditem)
if minetest.get_modpath("playerphysics") then if minetest.get_modpath("playerphysics") then

View File

@ -79,11 +79,11 @@ local function register_potion(def)
return function() end return function() end
end end
local function get_arrow_fun(effect, sp_dur) local function get_arrow_fun(effect, dur)
if def.is_dur then if def.is_dur then
return function(player) def.on_use(player, effect, sp_dur) end return function(player) def.on_use(player, effect, dur) end
elseif def.effect then elseif def.effect then
return function(player) def.on_use(player, effect, sp_dur) end return function(player) def.on_use(player, effect, dur) end
end end
-- covers case of no effect (water, awkward, mundane) -- covers case of no effect (water, awkward, mundane)
return function() end return function() end
@ -125,8 +125,8 @@ local function register_potion(def)
end end
local arrow_def = { local arrow_def = {
tt = get_tt(def._tt, def.effect, splash_dur), tt = get_tt(def._tt, def.effect, dur/8.),
potion_fun = get_arrow_fun(def.effect, splash_dur), potion_fun = get_arrow_fun(def.effect, dur/8.),
} }
if def.color then if def.color then
@ -208,9 +208,15 @@ local function register_potion(def)
} }
end end
local arrow_def_2 = {
tt = get_tt(def._tt_2, effect_II, dur_2/8.),
potion_fun = get_arrow_fun(effect_II, dur_2/8.),
}
if def.color then if def.color then
mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2) mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2)
mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2) mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2)
mcl_potions.register_arrow(def.name.."_2", S(def.description.." Arrow "..desc_mod), def.color, arrow_def_2)
end end
end end
@ -254,9 +260,14 @@ local function register_potion(def)
tt = get_tt(def._tt_plus, def.effect, ling_dur_pl), tt = get_tt(def._tt_plus, def.effect, ling_dur_pl),
potion_fun = get_lingering_fun(def.effect, ling_dur_pl), potion_fun = get_lingering_fun(def.effect, ling_dur_pl),
} }
local arrow_def_pl = {
tt = get_tt(def._tt_pl, def.effect, dur_pl/8.),
potion_fun = get_arrow_fun(def.effect, dur_pl/8.),
}
if def.color then if def.color then
mcl_potions.register_splash(def.name.."_plus", S("Splash "..def.description.." +"), def.color, splash_def_pl) mcl_potions.register_splash(def.name.."_plus", S("Splash "..def.description.." +"), def.color, splash_def_pl)
mcl_potions.register_lingering(def.name.."_plus", S("Lingering "..def.description.." +"), def.color, ling_def_pl) mcl_potions.register_lingering(def.name.."_plus", S("Lingering "..def.description.." +"), def.color, ling_def_pl)
mcl_potions.register_arrow(def.name.."_plus", S(def.description.." Arrow ".." +"), def.color, arrow_def_pl)
end end
end end

View File

@ -435,6 +435,16 @@ function mcl_potions.register_arrow(name, desc, color, def)
{'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'} {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'}
} }
}) })
minetest.register_craft({
output = 'mcl_potions:'..name..'_arrow 8',
recipe = {
{'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'},
{'mcl_bows:arrow','mcl_potions:'..name..'_lingering','mcl_bows:arrow'},
{'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'}
}
})
end end
if minetest.get_modpath("doc_identifier") ~= nil then if minetest.get_modpath("doc_identifier") ~= nil then