Fix and improvement Potions mod
parent
f694a8cbda
commit
084d2d1ac3
|
@ -1,7 +1,7 @@
|
|||
playereffects
|
||||
vessels
|
||||
playerphysics?
|
||||
default?
|
||||
vessels?
|
||||
flowers?
|
||||
farming?
|
||||
intllib?
|
||||
|
|
|
@ -8,6 +8,22 @@ end
|
|||
local ppa = minetest.get_modpath("playerphysics")
|
||||
|
||||
pep = {}
|
||||
|
||||
function return_empty_bottle(potiondef, user, itemstack)
|
||||
local inventory = user:get_inventory()
|
||||
local empty_vessel = "vessels:glass_bottle"
|
||||
if (itemstack:is_empty()) then
|
||||
return ItemStack(empty_vessel)
|
||||
else
|
||||
if inventory:room_for_item("main", "vessels:glass_bottle") then
|
||||
inventory:add_item("main", "vessels:glass_bottle")
|
||||
else
|
||||
minetest.add_item(user:getpos(), empty_vessel)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
function pep.register_potion(potiondef)
|
||||
local on_use
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
@ -32,8 +48,10 @@ function pep.register_potion(potiondef)
|
|||
if(potiondef.effect_type ~= nil) then
|
||||
playereffects.apply_effect_type(potiondef.effect_type, potiondef.duration, user)
|
||||
itemstack:take_item()
|
||||
itemstack = return_empty_bottle(potiondef, user, itemstack)
|
||||
else
|
||||
itemstack:take_item()
|
||||
itemstack = return_empty_bottle(potiondef, user, itemstack)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
@ -52,11 +70,7 @@ end
|
|||
pep.moles = {}
|
||||
|
||||
function pep.enable_mole_mode(playername)
|
||||
pep.moles[playername] = true
|
||||
end
|
||||
|
||||
function pep.disable_mole_mode(playername)
|
||||
pep.moles[playername] = false
|
||||
pep.moles[playername] = minetest.is_singleplayer()
|
||||
end
|
||||
|
||||
function pep.yaw_to_vector(yaw)
|
||||
|
@ -230,9 +244,6 @@ playereffects.register_effect_type("pepbreath", S("Perfect breath"), "pep_breath
|
|||
playereffects.register_effect_type("pepmole", S("Mole mode"), "pep_mole.png", {"autodig"},
|
||||
function(player)
|
||||
pep.enable_mole_mode(player:get_player_name())
|
||||
end,
|
||||
function(effect, player)
|
||||
pep.disable_mole_mode(player:get_player_name())
|
||||
end
|
||||
)
|
||||
|
||||
|
|
|
@ -168,9 +168,9 @@ function playereffects.apply_effect_type(effect_type_id, duration, player, repea
|
|||
end
|
||||
end
|
||||
|
||||
--[[ show no more than 20 effects on the screen, so that hud_update does not need to be called so often ]]
|
||||
--[[ show no more than 10 effects on the screen, so that hud_update does not need to be called so often ]]
|
||||
local text_id, icon_id
|
||||
if(free_hudpos <= 20) then
|
||||
if(free_hudpos <= 10) then
|
||||
text_id, icon_id = playereffects.hud_effect(effect_type_id, player, free_hudpos, duration, repeat_interval_time_left)
|
||||
local hudinfo = {
|
||||
text_id = text_id,
|
||||
|
@ -507,7 +507,7 @@ function playereffects.hud_effect(effect_type_id, player, pos, time_left, repeat
|
|||
alignment = { x = -1, y = 0 },
|
||||
direction = 1,
|
||||
number = color,
|
||||
offset = { x = -5, y = pos*20 }
|
||||
offset = { x = -5, y = pos*30 }
|
||||
})
|
||||
if(playereffects.effect_types[effect_type_id].icon ~= nil) then
|
||||
icon_id = player:hud_add({
|
||||
|
@ -518,7 +518,7 @@ function playereffects.hud_effect(effect_type_id, player, pos, time_left, repeat
|
|||
text = playereffects.effect_types[effect_type_id].icon,
|
||||
alignment = { x = -1, y=0 },
|
||||
direction = 0,
|
||||
offset = { x = -186, y = pos*20 },
|
||||
offset = { x = -200, y = pos*30 },
|
||||
})
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue