Potions: update with improvements and cleanup

This commit is contained in:
MoNTE48 2020-04-28 21:36:40 +02:00
parent bd939e2163
commit 3daef9bfbe
15 changed files with 617 additions and 578 deletions

View File

@ -1,3 +1,4 @@
default
mesecons_pistons
mesecons_solarpanel
pep

View File

@ -44,6 +44,7 @@ minetest.register_alias("mesecons_solarpanel:solar_panel_inverted_off", "mesecon
minetest.register_alias("mesecons_solarpanel:solar_panel_inverted_on", "mesecons_solarpanel:solar_panel_on")
--== Potions ==--
minetest.register_alias("potions:glass_bottle", "vessels:glass_bottle")
minetest.register_alias("potionspack:antigravity", "pep:grav0")
minetest.register_alias("potionspack:antigravityii", "pep:gravreset")
minetest.register_alias("potionspack:speed", "pep:speedminus")

View File

@ -1,2 +1,3 @@
default
experience?
pep?

View File

@ -1,6 +1,3 @@
playereffects
vessels
playerphysics?
default?
flowers?
farming?

View File

@ -1,142 +1,454 @@
local ppa = minetest.get_modpath("playerphysics")
pep = {}
-- Intllib
local S = intllib.make_gettext_pair()
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")
--
-- Apply Potion
--
local function apply_potion(player, pos, potion)
-- Particles
minetest.add_particlespawner({
amount = 50,
time = 0.2,
minpos = pos,
maxpos = pos,
minvel = {x = -1, y = 2, z = -1},
maxvel = {x = 1, y = 2, z = 1},
minacc = {x = 0, y = -4, z = 0},
maxacc = {x = 0, y = -8, z = 0},
minexptime = 2,
maxexptime = 2,
minsize = 0.5,
maxsize = 1.5,
collisiondetection = false,
vertical = false,
glow = 3,
texture = potion:gsub(":", "_") .. "_particle.png"
})
local def = minetest.registered_craftitems[potion]
if def.effect_type then
playereffects.apply_effect_type(def.effect_type, def.duration, player)
minetest.sound_play("mobs_spell",
{pos = pos, max_hear_distance = 10})
end
end
--
-- Throw Potion
--
local function throw_potion(player, potion)
local ppos = player:get_pos()
if not minetest.is_valid_pos(ppos) then
return
end
local function throw_potion_impact(_, ipos, _, hit_object)
minetest.sound_play("default_break_glass",
{pos = ipos, max_hear_distance = 20})
if hit_object and hit_object:is_player() then
apply_potion(hit_object, ipos, potion)
else
minetest.add_item(user:get_pos(), empty_vessel)
-- player search in the affected area
for _, obj in pairs(minetest.get_objects_inside_radius(ipos, 1.5)) do
if obj:is_player() then
apply_potion(obj, ipos, potion)
break
end
end
end
end
local obj = minetest.item_throw(potion, player,
19, 0, throw_potion_impact)
if obj then
local def = minetest.registered_craftitems[potion]
local inventory_image = def and def.inventory_image
if inventory_image then
obj:set_properties({
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {inventory_image}
})
end
local ent = obj:get_luaentity()
if ent then
minetest.sound_play("throwing_sound", {
pos = ppos, gain = 0.7, max_hear_distance = 10})
else
obj:remove()
end
end
end
--
-- Use Potion
--
local function use_potion(itemstack, user, pointed_thing, throw)
if pointed_thing.type == "node" then
local under = pointed_thing.under
local node = minetest.get_node(under)
local node_def = minetest.registered_nodes[node.name]
if node_def and node_def.on_rightclick and
not (user and user:is_player() and
user:get_player_control().sneak) then
return node_def.on_rightclick(under, node, user, itemstack,
pointed_thing) or itemstack
end
end
local potion = itemstack:get_name()
local pos = user:get_pos()
if throw then
-- Throwing
throw_potion(user, potion)
else
-- Drinking
pos.y = pos.y + 1.2
apply_potion(user, pos, potion)
end
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(user:get_player_name())) or
not minetest.is_singleplayer() then
itemstack:take_item()
if not throw then
local inventory = user:get_inventory()
local empty_vessel = "vessels:glass_bottle"
if inventory:room_for_item("main", empty_vessel) then
inventory:add_item("main", empty_vessel)
else
minetest.add_item(pos, empty_vessel)
end
end
end
return itemstack
end
function pep.register_potion(potiondef)
local on_use
on_use = function(itemstack, user, pointed_thing)
-- Particles
minetest.add_particlespawner({
amount = 30,
time = 0.1,
minpos = pointed_thing.above,
maxpos = pointed_thing.above,
minvel = {x = -1, y = 1, z = -1},
maxvel = {x = 1, y = 2, z = 1},
minacc = {x = 0, y = -5, z = 0},
maxacc = {x = 0, y = -9, z = 0},
minexptime = 1,
maxexptime = 3,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "pep_"..potiondef.basename.."_particle.png"
local potionname = potiondef.basename
if potiondef.recipe then
minetest.register_craft({
type = "shapeless",
output = "pep:" .. potionname,
recipe = potiondef.recipe
})
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
minetest.register_craftitem("pep:"..potiondef.basename, {
minetest.register_craftitem("pep:" .. potionname, {
description = S(potiondef.contentstring),
_doc_items_longdesc = S(potiondef.longdesc),
_doc_items_usagehelp = S("Hold it in your hand, then left-click to drink it."),
inventory_image = "pep_"..potiondef.basename..".png",
wield_image = "pep_"..potiondef.basename..".png",
on_use = on_use,
inventory_image = "pep_" .. potionname .. ".png",
wield_image = "pep_" .. potionname .. ".png",
groups = {vessel = 1, potion = 1},
effect_type = potiondef.effect_type,
duration = potiondef.duration or 0,
-- drink potion
on_place = use_potion,
on_secondary_use = use_potion,
-- throw potion
on_use = function(itemstack, user, pointed_thing)
return use_potion(itemstack, user, pointed_thing, true)
end
})
end
pep.moles = {}
--
-- Physics
--
function pep.enable_mole_mode(playername)
pep.moles[playername] = true
end
local ppa = minetest.get_modpath("playerphysics")
function pep.disable_mole_mode(playername)
pep.moles[playername] = false
end
function pep.yaw_to_vector(yaw)
local tau = math.pi*2
yaw = yaw % tau
if yaw < tau/8 then
return { x=0, y=0, z=1}
elseif yaw < (3/8)*tau then
return { x=-1, y=0, z=0 }
elseif yaw < (5/8)*tau then
return { x=0, y=0, z=-1 }
elseif yaw < (7/8)*tau then
return { x=1, y=0, z=0 }
local add_physic = function(player, attribute, value)
if ppa then
playerphysics.add_physics_factor(player, attribute, "pep:" .. attribute, value)
else
return { x=0, y=0, z=1}
player:set_physics_override({[attribute] = value})
end
end
local remove_physic = function(player, attribute)
if ppa then
playerphysics.remove_physics_factor(player, attribute, "pep:" .. attribute)
else
player:set_physics_override({[attribute] = 1})
end
end
--
-- Potions
--
playereffects.register_effect_type("pepspeedplus", S("High Speed"), "pep_speedplus.png", {"speed"},
function(player)
add_physic(player, "speed", 2.5)
end,
function(_, player)
remove_physic(player, "speed")
end
)
pep.register_potion({
basename = "speedplus",
contentstring = "Running Potion",
longdesc = "Drinking it will make you run faster for 60 seconds.",
effect_type = "pepspeedplus",
duration = 60,
recipe = {
"default:pine_sapling", "default:cactus", "flowers:oxeye_daisy",
"default:junglegrass", "vessels:glass_bottle"
}
})
playereffects.register_effect_type("pepspeedminus", S("Low Speed"), "pep_speedminus.png", {"speed"},
function(player)
add_physic(player, "speed", 0.5)
end,
function(_, player)
remove_physic(player, "speed")
end
)
pep.register_potion({
basename = "speedminus",
contentstring = "Slug Potion",
longdesc = "Drinking it will make you walk slower for 60 seconds.",
effect_type = "pepspeedminus",
duration = 60,
recipe = {"default:dry_grass", "default:ice", "vessels:glass_bottle"}
})
playereffects.register_effect_type("pepbreath", S("Perfect Breath"), "pep_breath.png", {"breath"},
function(player)
if player:get_breath() < 10 then
player:set_breath(10)
end
end,
nil, nil, nil, 2
)
pep.register_potion({
basename = "breath",
contentstring = "Air Potion",
longdesc = "Drinking it gives you breath underwater for 60 seconds.",
effect_type = "pepbreath",
duration = 30,
recipe = {
"default:sugarcane", "default:sugarcane", "default:sugarcane",
"default:sugarcane", "default:sugarcane", "default:sugarcane",
"default:sugarcane", "default:sugarcane", "vessels:glass_bottle"
}
})
playereffects.register_effect_type("pepregen", S("Regeneration"), "pep_regen.png", {"health"},
function(player)
player:set_hp(player:get_hp() + 1)
end,
nil, nil, nil, 2
)
pep.register_potion({
basename = "regen",
contentstring = "Healing Potion",
longdesc = "Drinking it makes you regenerate health. Every 2 seconds, you get 1 HP, 20 times in total.",
effect_type = "pepregen",
duration = 20,
recipe = {
"default:cactus", "farming:flour", "flowers:mushroom_brown",
"vessels:glass_bottle"
}
})
playereffects.register_effect_type("pepregen2", S("Regeneration II"), "pep_regen2.png", {"health"},
function(player)
player:set_hp(player:get_hp() + 2)
end,
nil, nil, nil, 1
)
pep.register_potion({
basename = "regen2",
contentstring = "Healing Potion II",
longdesc = "Drinking it makes you regenerate health quickly. Every second you get 2 HP, 30 times in total.",
effect_type = "pepregen2",
duration = 30,
recipe = {"default:gold_ingot", "farming:flour", "pep:regen"}
})
playereffects.register_effect_type("pepgrav0", S("No Gravity"), "pep_grav0.png", {"gravity"},
function(player)
add_physic(player, "gravity", 0)
end,
function(_, player)
remove_physic(player, "gravity")
end
)
pep.register_potion({
basename = "grav0",
contentstring = "Non-Gravity Potion",
longdesc = "When you drink this potion, gravity stops affecting you, as if you were in space. The effect lasts for 30 seconds.",
effect_type = "pepgrav0",
duration = 30,
recipe = {"mesecons:wire_00000000_off", "vessels:glass_bottle"}
})
playereffects.register_effect_type("pepgravreset", S("Gravity Neutralizer"), "pep_gravreset.png", {"gravity"},
function() end, function() end)
pep.register_potion({
basename = "gravreset",
contentstring = "Gravity Neutralizer Potion",
longdesc = "Drinking it will stop all gravity effects you currently have.",
effect_type = "pepgravreset",
recipe = {"pep:grav0", "default:steel_ingot"}
})
playereffects.register_effect_type("pepjumpplus", S("High Jump"), "pep_jumpplus.png", {"jump"},
function(player)
add_physic(player, "jump", 2.5)
end,
function(_, player)
remove_physic(player, "jump")
end
)
pep.register_potion({
basename = "jumpplus",
contentstring = "High Jumping Potion",
longdesc = "Drinking it will make you jump higher for 60 seconds.",
effect_type = "pepjumpplus",
duration = 60,
recipe = {
"flowers:tulip", "default:grass", "mesecons:wire_00000000_off",
"mesecons:wire_00000000_off", "vessels:glass_bottle"
}
})
playereffects.register_effect_type("pepjumpminus", S("Low Jump"), "pep_jumpminus.png", {"jump"},
function(player)
add_physic(player, "jump", 0.5)
end,
function(_, player)
remove_physic(player, "jump")
end
)
pep.register_potion({
basename = "jumpminus",
contentstring = "Low Jumping Potion",
longdesc = "Drinking it will make you jump lower for 60 seconds.",
effect_type = "pepjumpminus",
duration = 60,
recipe = {
"default:leaves", "default:jungleleaves", "default:steel_ingot",
"flowers:oxeye_daisy", "vessels:glass_bottle"
}
})
local dark = {}
playereffects.register_effect_type("pepnightvision", S("Night Vision"), "pep_nightvision.png", {"nightvision"},
function(player)
player:override_day_night_ratio(
math.min(1, minetest.get_timeofday() + 0.6))
if not dark[player:get_player_name()] then
local hud = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
scale = {x = -100, y = -100},
text = "pep_dark.png"
})
dark[player:get_player_name()] = hud
end
end,
function(_, player)
player:override_day_night_ratio(nil)
player:hud_remove(dark[player:get_player_name()])
dark[player:get_player_name()] = nil
end
)
pep.register_potion({
basename = "nightvision",
contentstring = "Night Vision Potion",
longdesc = "Drinking it, you will see in the dark for 60 seconds",
effect_type = "pepnightvision",
duration = 60,
recipe = {
"default:glowstone_dust","default:glowstone_dust", "default:glowstone_dust",
"flowers:mushroom_red", "flowers:mushroom_brown", "vessels:glass_bottle"
}
})
--
-- Invisible
--
invisibility = {} -- for compatibility with other mods
playereffects.register_effect_type("pepinvisible", S("Invisible"), "pep_invisible.png", {"invisible"},
function(player)
player:set_properties({
visual_size = {x = 0, y = 0}
})
local nametag = player:get_nametag_attributes()
nametag.color.a = 0
player:set_nametag_attributes(nametag)
invisibility[player:get_player_name()] = true
end,
function(_, player)
player:set_properties({
visual_size = {x = 1, y = 1}
})
local nametag = player:get_nametag_attributes()
nametag.color.a = 255
player:set_nametag_attributes(nametag)
invisibility[player:get_player_name()] = nil
end,
nil, false
)
pep.register_potion({
basename = "invisible",
contentstring = "Invisible Potion",
longdesc = "Drinking it, you will invisible for 30 seconds",
effect_type = "pepinvisible",
duration = 30,
recipe = {
"default:sapling", "default:junglesapling", "default:pine_sapling",
"default:acacia_sapling", "default:birch_sapling", "flowers:mushroom_red",
"vessels:glass_bottle"
}
})
--
-- Mole
--
pep.moles = {}
function pep.moledig(playername)
local player = minetest.get_player_by_name(playername)
local yaw = player:get_look_horizontal()
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
local pos = vector.round(player:get_pos())
local v = pep.yaw_to_vector(yaw)
local digpos1 = vector.add(pos, dir)
local digpos2 = {x = digpos1.x, y = digpos1.y + 1, z = digpos1.z}
local digpos1 = vector.add(pos, v)
local digpos2 = { x = digpos1.x, y = digpos1.y+1, z = digpos1.z }
local function dig(pos)
if not minetest.is_protected(pos, playername) then
local node = minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
if def.walkable and def.diggable and
(def.can_dig == nil or def.can_dig(pos, player)) then
minetest.node_dig(pos, node, player)
local try_dig = function(pos)
local n = minetest.get_node(pos)
local ndef = minetest.registered_nodes[n.name]
if ndef.walkable and ndef.diggable then
if ndef.can_dig ~= nil then
if ndef.can_dig() then
return true
else
return false
if def.sounds and def.sounds.dug then
minetest.sound_play(def.sounds.dug, {pos = pos})
end
else
return true
end
else
return false
end
end
local dig = function(pos)
if try_dig(pos) then
local n = minetest.get_node(pos)
local ndef = minetest.registered_nodes[n.name]
if ndef.sounds ~= nil then
minetest.sound_play(ndef.sounds.dug, { pos = pos })
end
-- TODO: Replace this code as soon Minetest removes support for this function
local drops = minetest.get_node_drops(n.name, "default:pick_steel")
minetest.dig_node(pos)
local inv = player:get_inventory()
local leftovers = {}
for i=1, #drops do
table.insert(leftovers, inv:add_item("main", drops[i]))
end
for i=1,#leftovers do
minetest.add_item(pos, leftovers[i])
end
end
end
@ -145,287 +457,32 @@ function pep.moledig(playername)
dig(digpos2)
end
if minetest.is_singleplayer() then
pep.timer = 0
minetest.register_globalstep(function(dtime)
pep.timer = pep.timer + dtime
if pep.timer > 0.5 then
for playername, is_mole in pairs(pep.moles) do
if is_mole then
pep.moledig(playername)
end
local mtimer = 0
minetest.register_globalstep(function(dtime)
mtimer = mtimer + dtime
if mtimer > 0.5 then
for playername, is_mole in pairs(pep.moles) do
if is_mole then
pep.moledig(playername)
end
pep.timer = 0
end
end)
end
mtimer = 0
end
end)
local add_physic = function(player, attribute, value)
if ppa then
playerphysics.add_physics_factor(player, attribute, "pep:"..attribute, value)
else
player:set_physics_override({[attribute]=value})
end
end
local remove_physic = function(player, attribute)
if ppa then
playerphysics.remove_physics_factor(player, attribute, "pep:"..attribute)
else
player:set_physics_override({[attribute]=1})
end
end
playereffects.register_effect_type("pepspeedplus", S("High speed"), "pep_speedplus.png", {"speed"},
playereffects.register_effect_type("pepmole", S("Autodig Mode"), "pep_mole.png", {"autodig"},
function(player)
add_physic(player, "speed", 2)
pep.moles[player:get_player_name()] = true
end,
function(effect, player)
remove_physic(player, "speed")
function(_, player)
pep.moles[player:get_player_name()] = false
end
)
playereffects.register_effect_type("pepspeedminus", S("Low speed"), "pep_speedminus.png", {"speed"},
function(player)
add_physic(player, "speed", 0.5)
end,
function(effect, player)
remove_physic(player, "speed")
end
)
playereffects.register_effect_type("pepspeedreset", S("Speed neutralizer"), "pep_speedreset.png", {"speed"},
function() end, function() end)
playereffects.register_effect_type("pepjumpplus", S("High jump"), "pep_jumpplus.png", {"jump"},
function(player)
add_physic(player, "jump", 2)
end,
function(effect, player)
remove_physic(player, "jump")
end
)
playereffects.register_effect_type("pepjumpminus", S("Low jump"), "pep_jumpminus.png", {"jump"},
function(player)
add_physic(player, "jump", 0.5)
end,
function(effect, player)
remove_physic(player, "jump")
end
)
playereffects.register_effect_type("pepjumpreset", S("Jump height neutralizer"), "pep_jumpreset.png", {"jump"},
function() end, function() end)
playereffects.register_effect_type("pepgrav0", S("No gravity"), "pep_grav0.png", {"gravity"},
function(player)
add_physic(player, "gravity", 0)
end,
function(effect, player)
remove_physic(player, "gravity")
end
)
playereffects.register_effect_type("pepgravreset", S("Gravity neutralizer"), "pep_gravreset.png", {"gravity"},
function() end, function() end)
playereffects.register_effect_type("pepregen", S("Regeneration"), "pep_regen.png", {"health"},
function(player)
player:set_hp(player:get_hp()+1)
end,
nil, nil, nil, 2
)
playereffects.register_effect_type("pepregen2", S("Strong regener."), "pep_regen2.png", {"health"},
function(player)
player:set_hp(player:get_hp()+2)
end,
nil, nil, nil, 1
)
playereffects.register_effect_type("pepbreath", S("Perfect breath"), "pep_breath.png", {"breath"},
function(player)
player:set_breath(player:get_breath()+2)
end,
nil, nil, nil, 1
)
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
)
pep.register_potion({
basename = "speedplus",
contentstring = "Running Potion",
longdesc = "Drinking it will make you run faster for 30 seconds.",
effect_type = "pepspeedplus",
duration = 30,
})
pep.register_potion({
basename = "speedminus",
contentstring = "Slug Potion",
longdesc = "Drinking it will make you walk slower for 30 seconds.",
effect_type = "pepspeedminus",
duration = 30,
})
pep.register_potion({
basename = "speedreset",
contentstring = "Speed Neutralizer Potion",
longdesc = "Drinking it will stop all speed effects you may currently have.",
effect_type = "pepspeedreset",
duration = 0
})
pep.register_potion({
basename = "breath",
contentstring = "Air Potion",
longdesc = "Drinking it gives you breath underwater for 30 seconds.",
effect_type = "pepbreath",
duration = 30,
})
pep.register_potion({
basename = "regen",
contentstring = "Weak Healing Potion",
longdesc = "Drinking it makes you regenerate health. Every 2 seconds, you get 1 HP, 15 times in total.",
effect_type = "pepregen",
duration = 15,
})
pep.register_potion({
basename = "regen2",
contentstring = "Strong Healing Potion",
longdesc = "Drinking it makes you regenerate health quickly. Every second you get 2 HP, 15 times in total.",
effect_type = "pepregen2",
duration = 15,
})
pep.register_potion({
basename = "grav0",
contentstring = "Non-Gravity Potion",
longdesc = "When you drink this potion, gravity stops affecting you, as if you were in space. The effect lasts for 20 seconds.",
effect_type = "pepgrav0",
duration = 20,
})
pep.register_potion({
basename = "gravreset",
contentstring = "Gravity Neutralizer Potion",
longdesc = "Drinking it will stop all gravity effects you currently have.",
effect_type = "pepgravreset",
duration = 0,
})
pep.register_potion({
basename = "jumpplus",
contentstring = "High Jumping Potion",
longdesc = "Drinking it will make you jump higher for 30 seconds.",
effect_type = "pepjumpplus",
duration = 30,
})
pep.register_potion({
basename = "jumpminus",
contentstring = "Low Jumping Potion",
longdesc = "Drinking it will make you jump lower for 30 seconds.",
effect_type = "pepjumpminus",
duration = 30,
})
pep.register_potion({
basename = "jumpreset",
contentstring = "Jump Neutralizer Potion",
longdesc = "Drinking it will stop all jumping effects you may currently have.",
effect_type = "pepjumpreset",
duration = 0,
})
pep.register_potion({
basename = "mole",
contentstring = "Mole Potion",
longdesc = "Drinking it will start an effect which will magically attempt to mine any two blocks in front of you horizontally, as if you were using a steel pickaxe on them. The effect lasts for 18 seconds.",
contentstring = "Autodig Potion",
longdesc = "Drinking it will start an effect which will attempt to mine any two blocks in front of you, as if you were using a diamond pickaxe on them. The effect lasts for 30 seconds.",
effect_type = "pepmole",
duration = 18,
duration = 30,
recipe = {"default:pick_steel", "default:shovel_steel", "vessels:glass_bottle"}
})
--[=[ register crafts ]=]
--[[ normal potions ]]
minetest.register_craft({
type = "shapeless",
output = "pep:breath",
recipe = { "default:sugarcane", "default:sugarcane", "default:sugarcane", "default:sugarcane",
"default:sugarcane", "default:sugarcane", "default:sugarcane", "default:sugarcane", "vessels:glass_bottle" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:speedminus",
recipe = { "default:dry_grass", "default:ice", "vessels:glass_bottle" }
})
if(minetest.get_modpath("flowers") ~= nil) then
minetest.register_craft({
type = "shapeless",
output = "pep:jumpplus",
recipe = { "flowers:tulip", "default:grass", "mesecons:wire_00000000_off",
"mesecons:wire_00000000_off", "vessels:glass_bottle" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:poisoner",
recipe = { "flowers:mushroom_red", "flowers:mushroom_red", "flowers:mushroom_red", "vessels:glass_bottle" }
})
if(minetest.get_modpath("farming") ~= nil) then
minetest.register_craft({
type = "shapeless",
output = "pep:regen",
recipe = { "default:cactus", "farming:flour", "flowers:mushroom_brown", "vessels:glass_bottle" }
})
end
end
if(minetest.get_modpath("farming") ~= nil) then
minetest.register_craft({
type = "shapeless",
output = "pep:regen2",
recipe = { "default:gold_ingot", "farming:flour", "pep:regen" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:jumpminus",
recipe = { "default:leaves", "default:jungleleaves", "default:steel_ingot", "flowers:oxeye_daisy", "vessels:glass_bottle" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:grav0",
recipe = { "mesecons:wire_00000000_off", "vessels:glass_bottle" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:mole",
recipe = { "default:pick_steel", "default:shovel_steel", "vessels:glass_bottle" },
})
minetest.register_craft({
type = "shapeless",
output = "pep:gravreset" ,
recipe = { "pep:grav0", "default:steel_ingot" }
})
end
minetest.register_craft({
type = "shapeless",
output = "pep:speedplus",
recipe = { "default:pine_sapling", "default:cactus", "flowers:oxeye_daisy", "default:junglegrass", "vessels:glass_bottle" }
})
--[[ independent crafts ]]
minetest.register_craft({
type = "shapeless",
output = "pep:speedreset",
recipe = { "pep:speedplus", "pep:speedminus" }
})
minetest.register_craft({
type = "shapeless",
output = "pep:jumpreset",
recipe = { "pep:jumpplus", "pep:jumpminus" }
})
--[[ aliases ]]
minetest.register_alias("potionspack:antigravity", "pep:grav0")
minetest.register_alias("potionspack:antigravityii", "pep:gravreset")
minetest.register_alias("potionspack:speed", "pep:speedminus")
minetest.register_alias("potionspack:speedii", "pep:speedplus")
minetest.register_alias("potionspack:inversion", "pep:speedreset")
minetest.register_alias("potionspack:confusion", "pep:breath")
minetest.register_alias("potionspack:whatwillthisdo", "pep:mole")
minetest.register_alias("potionspack:instanthealth", "pep:regen")
minetest.register_alias("potionspack:instanthealthii", "pep:regen2")
minetest.register_alias("potionspack:regen", "pep:regen")
minetest.register_alias("potionspack:regenii", "pep:regen2")
minetest.register_alias("potionspack:harming", "pep:gravreset")
minetest.register_alias("potionspack:harmingii", "pep:gravreset")

View File

@ -0,0 +1,27 @@
# Effects
High Speed=Ускорение
Low Speed=Замедление
Perfect Breath=Дыхание
Regeneration=Регенерация
Regeneration II=Регенерация II
No Gravity=Невесомость
Gravity Neutralizer=Нейтрализ. Невесомости
High Jump=Сильный Прыжок
Low Jump=Слабый Прыжок
Night Vision=Ночное Видение
Invisible=Невидимость
Autodig Mode=Режим Автодобычи
# Potions
Running Potion=Зелье Ускорения
Slug Potion=Зелье Замедления
Air Potion=Зелье Дыхания
Healing Potion=Зелье Регенерации
Healing Potion II=Зелье Регенерации II
Non-Gravity Potion=Зелье Невесомости
Gravity Neutralizer Potion=Зелье Нейтрализации Невесомости
High Jumping Potion=Зелье Сильных Прыжков
Low Jumping Potion=Зелье Слабых Прыжков
Night Vision Potion=Зелье Ночного Видения
Invisible Potion=Зелье Невидимости
Autodig Potion=Зелье Автодобычи

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 413 B

View File

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 333 B

View File

@ -6,12 +6,12 @@ playereffects = {}
playereffects.groups = {}
--[[ table containing all the HUD info tables, indexed by player names.
A single HUD info table is formatted like this: { text_id = 1, icon_id=2, pos = 0 }
A single HUD info table is formatted like this: {text_id = 1, icon_id=2, pos = 0}
Where: text_id: HUD ID of the textual effect description
icon_id: HUD ID of the effect icon (optional)
pos: Y offset factor (starts with 0)
icon_id: HUD ID of the effect icon (optional)
pos: Y offset factor (starts with 0)
Example of full table:
{ ["player1"] = {{ text_id = 1, icon_id=4, pos = 0 }}, ["player2] = { { text_id = 5, icon_id=6, pos = 0 }, { text_id = 7, icon_id=8, pos = 1 } } }
{["player1"] = {{text_id = 1, icon_id = 4, pos = 0}}, ["player2] = {{text_id = 5, icon_id=6, pos = 0}, {text_id = 7, icon_id=8, pos = 1}}}
]]
playereffects.hudinfos = {}
@ -28,7 +28,6 @@ playereffects.inactive_effects = {}
-- Variable for counting the effect_id
playereffects.last_effect_id = 0
--[[
Settings for Player Effects
]]
@ -36,36 +35,30 @@ playereffects.last_effect_id = 0
-- Whether to use the HUD to expose the active effects to players (true or false)
playereffects.use_hud = true
-- Whether to use save (true, false or minetest.is_singleplayer())
playereffects.save = minetest.is_singleplayer()
-- Whether to use autosave (true or false)
playereffects.use_autosave = false
local use_autosave = false
-- The time interval between autosaves, in seconds (only used when use_autosave is true)
playereffects.autosave_time = 10
local autosave_time = 10
-- Intllib
local S = intllib.make_gettext_pair()
--[=[ Load inactive_effects and last_effect_id from playereffects, if this file exists ]=]
if playereffects.save then
do
local filepath = minetest.get_worldpath().."/playereffects"
local file = io.open(filepath, "r")
if file then
minetest.log("action", "[playereffects] playereffects opened.")
local string = file:read()
io.close(file)
if (string ~= nil) then
local savetable = minetest.deserialize(string)
playereffects.inactive_effects = savetable.inactive_effects
-- minetest.debug("[playereffects] playereffects successfully read.")
-- minetest.debug("[playereffects] inactive_effects = "..dump(playereffects.inactive_effects))
playereffects.last_effect_id = savetable.last_effect_id
-- minetest.debug("[playereffects] last_effect_id = "..dump(playereffects.last_effect_id))
end
--[=[ Load inactive_effects and last_effect_id from playereffects, if this file exists ]=]
do
local filepath = minetest.get_worldpath() .. "/playereffects"
local file = io.open(filepath, "r")
if file then
minetest.log("action", "[playereffects] playereffects loading...")
local string = file:read()
io.close(file)
if string ~= nil then
local savetable = minetest.deserialize(string)
playereffects.inactive_effects = savetable.inactive_effects
-- minetest.debug("[playereffects] playereffects successfully read.")
-- minetest.debug("[playereffects] inactive_effects = " .. dump(playereffects.inactive_effects))
-- playereffects.last_effect_id = savetable.last_effect_id
-- minetest.debug("[playereffects] last_effect_id = " .. dump(playereffects.last_effect_id))
end
end
end
@ -82,123 +75,98 @@ function playereffects.register_effect_type(effect_type_id, description, icon, g
effect_type.apply = apply
effect_type.groups = groups
effect_type.icon = icon
if cancel ~= nil then
effect_type.cancel = cancel
else
effect_type.cancel = function() end
end
if hidden ~= nil then
effect_type.hidden = hidden
else
effect_type.hidden = false
end
if cancel_on_death ~= nil then
effect_type.cancel_on_death = cancel_on_death
else
effect_type.cancel_on_death = true
end
effect_type.cancel = cancel and cancel or function() end
effect_type.hidden = hidden and hidden or false
effect_type.cancel_on_death = cancel_on_death and cancel_on_death or true
effect_type.repeat_interval = repeat_interval
playereffects.effect_types[effect_type_id] = effect_type
-- minetest.log("action", "[playereffects] Effect type "..effect_type_id.." registered!")
-- minetest.log("action", "[playereffects] Effect type " .. effect_type_id .. " registered!")
end
function playereffects.apply_effect_type(effect_type_id, duration, player, repeat_interval_time_left)
local start_time = os.time()
local is_player = false
if (type(player)=="userdata") then
if (player.is_player ~= nil) then
if (player:is_player() == true) then
is_player = true
end
end
end
if (is_player == false) then
minetest.log("error", "[playereffects] Attempted to apply effect type "..effect_type_id.." to a non-player!")
if type(player) == "userdata" and not (player.is_player or player:is_player()) then
minetest.log("error", "[playereffects] Attempted to apply effect type " .. effect_type_id .. " to a non-player!")
return false
end
local playername = player:get_player_name()
local groups = playereffects.effect_types[effect_type_id].groups
for k,v in pairs(groups) do
for _, v in pairs(groups) do
playereffects.cancel_effect_group(v, playername)
end
local metadata
if (playereffects.effect_types[effect_type_id].repeat_interval == nil) then
if not playereffects.effect_types[effect_type_id].repeat_interval then
local status = playereffects.effect_types[effect_type_id].apply(player)
if (status == false) then
minetest.log("action", "[playereffects] Attempt to apply effect type "..effect_type_id.." to player "..playername.." failed!")
if status == false then
minetest.log("action", "[playereffects] Attempt to apply effect type " .. effect_type_id .. " to player " .. playername .. " failed!")
return false
else
metadata = status
end
end
local effect_id = playereffects.next_effect_id()
local smallest_hudpos
local biggest_hudpos = -1
local free_hudpos
if (playereffects.hudinfos[playername] == nil) then
playereffects.hudinfos[playername] = {}
end
local hudinfos = playereffects.hudinfos[playername]
for effect_id, hudinfo in pairs(hudinfos) do
for _, hudinfo in pairs(hudinfos) do
local hudpos = hudinfo.pos
if (hudpos > biggest_hudpos) then
if hudpos > biggest_hudpos then
biggest_hudpos = hudpos
end
if (smallest_hudpos == nil) then
if not smallest_hudpos then
smallest_hudpos = hudpos
elseif (hudpos < smallest_hudpos) then
elseif hudpos < smallest_hudpos then
smallest_hudpos = hudpos
end
end
if (smallest_hudpos == nil) then
if not smallest_hudpos then
free_hudpos = 0
elseif (smallest_hudpos >= 0) then
elseif smallest_hudpos >= 0 then
free_hudpos = smallest_hudpos - 1
else
free_hudpos = biggest_hudpos + 1
end
local repeat_interval = playereffects.effect_types[effect_type_id].repeat_interval
if (repeat_interval ~= nil) then
if (repeat_interval_time_left == nil) then
repeat_interval_time_left = repeat_interval
end
if repeat_interval ~= nil then
repeat_interval_time_left = repeat_interval_time_left and repeat_interval_time_left or repeat_interval
end
--[[ 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 <= 10) 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,
icon_id = icon_id,
pos = free_hudpos,
text_id = text_id,
icon_id = icon_id,
pos = free_hudpos
}
playereffects.hudinfos[playername][effect_id] = hudinfo
else
text_id, icon_id = nil, nil
playereffects.hud_update(player)
end
local effect = {
playername = playername,
effect_id = effect_id,
effect_type_id = effect_type_id,
start_time = start_time,
repeat_interval_start_time = start_time,
time_left = duration,
repeat_interval_time_left = repeat_interval_time_left,
metadata = metadata,
playername = playername,
effect_id = effect_id,
effect_type_id = effect_type_id,
start_time = start_time,
repeat_interval_start_time = start_time,
time_left = duration,
repeat_interval_time_left = repeat_interval_time_left,
metadata = metadata
}
playereffects.effects[effect_id] = effect
if (repeat_interval ~= nil) then
minetest.after(repeat_interval_time_left, playereffects.repeater, effect_id, duration, player, playereffects.effect_types[effect_type_id].apply)
if repeat_interval ~= nil then
minetest.after(repeat_interval_time_left, playereffects.repeater, effect_id,
duration, player, playereffects.effect_types[effect_type_id].apply)
else
minetest.after(duration, function(effect_id) playereffects.cancel_effect(effect_id) end, effect_id)
end
@ -208,36 +176,30 @@ end
function playereffects.repeater(effect_id, repetitions, player, apply)
local effect = playereffects.effects[effect_id]
if (effect ~= nil) then
local repetitions = effect.time_left
if effect ~= nil then
repetitions = effect.time_left
apply(player)
repetitions = repetitions - 1
effect.time_left = repetitions
if (repetitions <= 0) then
if repetitions <= 0 then
playereffects.cancel_effect(effect_id)
else
local repeat_interval = playereffects.effect_types[effect.effect_type_id].repeat_interval
effect.repeat_interval_time_left = repeat_interval
effect.repeat_interval_start_time = os.time()
minetest.after(
repeat_interval,
playereffects.repeater,
effect_id,
repetitions,
player,
apply
)
minetest.after(repeat_interval, playereffects.repeater, effect_id,
repetitions, player, apply)
end
end
end
function playereffects.cancel_effect_type(effect_type_id, cancel_all, playername)
local effects = playereffects.get_player_effects(playername)
if (cancel_all==nil) then cancel_all = false end
for e=1, #effects do
if (effects[e].effect_type_id == effect_type_id) then
cancel_all = cancel_all and cancel_all or false
for e = 1, #effects do
if effects[e].effect_type_id == effect_type_id then
playereffects.cancel_effect(effects[e].effect_id)
if (cancel_all==false) then
if not cancel_all then
return
end
end
@ -246,12 +208,11 @@ end
function playereffects.cancel_effect_group(groupname, playername)
local effects = playereffects.get_player_effects(playername)
for e=1,#effects do
for e = 1, #effects do
local effect = effects[e]
local thesegroups = playereffects.effect_types[effect.effect_type_id].groups
local delete = false
for g=1,#thesegroups do
if (thesegroups[g] == groupname) then
for g = 1, #thesegroups do
if thesegroups[g] == groupname then
playereffects.cancel_effect(effect.effect_id)
break
end
@ -262,23 +223,20 @@ end
function playereffects.get_remaining_effect_time(effect_id)
local now = os.time()
local effect = playereffects.effects[effect_id]
if (effect ~= nil) then
return (effect.time_left - os.difftime(now, effect.start_time))
else
return nil
end
return effect and (effect.time_left - os.difftime(now, effect.start_time)) or nil
end
function playereffects.cancel_effect(effect_id)
local effect = playereffects.effects[effect_id]
if (effect ~= nil) then
if effect ~= nil then
local player = minetest.get_player_by_name(effect.playername)
local hudinfo = playereffects.hudinfos[effect.playername][effect_id]
if (hudinfo ~= nil) then
if (hudinfo.text_id~=nil) then
if hudinfo ~= nil then
if hudinfo.text_id ~= nil then
player:hud_remove(hudinfo.text_id)
end
if (hudinfo.icon_id~=nil) then
if hudinfo.icon_id ~= nil then
player:hud_remove(hudinfo.icon_id)
end
playereffects.hudinfos[effect.playername][effect_id] = nil
@ -289,26 +247,26 @@ function playereffects.cancel_effect(effect_id)
end
function playereffects.get_player_effects(playername)
if (minetest.get_player_by_name(playername) ~= nil) then
local effects = {}
for k,v in pairs(playereffects.effects) do
if (v.playername == playername) then
table.insert(effects, v)
local effects = {}
if minetest.get_player_by_name(playername) ~= nil then
for _, v in pairs(playereffects.effects) do
if v.playername == playername then
effects[#effects+1] = v
end
end
return effects
else
return {}
end
return effects
end
function playereffects.has_effect_type(playername, effect_type_id)
local pe = playereffects.get_player_effects(playername)
for i=1,#pe do
for i = 1, #pe do
if pe[i].effect_type_id == effect_type_id then
return true
end
end
return false
end
@ -317,18 +275,20 @@ function playereffects.save_to_file()
local save_time = os.time()
local savetable = {}
local inactive_effects = {}
for id,effecttable in pairs(playereffects.inactive_effects) do
local playername = id
if (inactive_effects[playername] == nil) then
for playername, effecttable in pairs(playereffects.inactive_effects) do
if inactive_effects[playername] == nil then
inactive_effects[playername] = {}
end
for i=1,#effecttable do
table.insert(inactive_effects[playername], effecttable[i])
local pinacteff = inactive_effects[playername]
for i = 1, #effecttable do
pinacteff[#pinacteff+1] = effecttable[i]
end
end
for id,effect in pairs(playereffects.effects) do
for _, effect in pairs(playereffects.effects) do
local new_duration, new_repeat_duration
if (playereffects.effect_types[effect.effect_type_id].repeat_interval ~= nil) then
if playereffects.effect_types[effect.effect_type_id].repeat_interval ~= nil then
new_duration = effect.time_left
new_repeat_duration = effect.repeat_interval_time_left - os.difftime(save_time, effect.repeat_interval_start_time)
else
@ -344,25 +304,29 @@ function playereffects.save_to_file()
playername = effect.playername,
metadata = effect.metadata
}
if (inactive_effects[effect.playername] == nil) then
inactive_effects[effect.playername] = {}
local player_inactive_effects_effect = inactive_effects[effect.playername]
player_inactive_effects_effect[#player_inactive_effects_effect+1] = new_effect
end
for playername, _ in pairs(inactive_effects) do
if #inactive_effects[playername] < 1 then
inactive_effects[playername] = nil
end
table.insert(inactive_effects[effect.playername], new_effect)
end
savetable.inactive_effects = inactive_effects
savetable.last_effect_id = playereffects.last_effect_id
-- savetable.last_effect_id = playereffects.last_effect_id
local savestring = minetest.serialize(savetable)
local filepath = minetest.get_worldpath().."/playereffects"
local filepath = minetest.get_worldpath() .. "/playereffects"
local file = io.open(filepath, "w")
if file then
file:write(savestring)
io.close(file)
minetest.log("action", "[playereffects] Wrote playereffects data into "..filepath..".")
minetest.log("action", "[playereffects] Wrote playereffects data into " .. filepath .. ".")
else
minetest.log("error", "[playereffects] Failed to write playereffects data into "..filepath..".")
minetest.log("error", "[playereffects] Failed to write playereffects data into " .. filepath .. ".")
end
end
@ -371,13 +335,12 @@ end
minetest.register_on_dieplayer(function(player)
local effects = playereffects.get_player_effects(player:get_player_name())
for e = 1, #effects do
if (playereffects.effect_types[effects[e].effect_type_id].cancel_on_death == true) then
if playereffects.effect_types[effects[e].effect_type_id].cancel_on_death then
playereffects.cancel_effect(effects[e].effect_id)
end
end
end)
minetest.register_on_leaveplayer(function(player)
local leave_time = os.time()
local playername = player:get_player_name()
@ -385,47 +348,47 @@ minetest.register_on_leaveplayer(function(player)
playereffects.hud_clear(player)
if (playereffects.inactive_effects[playername] == nil) then
playereffects.inactive_effects[playername] = {}
end
for e=1,#effects do
local inactive_effects = playereffects.inactive_effects[playername]
for e = 1, #effects do
local new_duration = effects[e].time_left - os.difftime(leave_time, effects[e].start_time)
local new_effect = effects[e]
new_effect.time_left = new_duration
table.insert(playereffects.inactive_effects[playername], new_effect)
inactive_effects[#inactive_effects+1] = new_effect
playereffects.cancel_effect(effects[e].effect_id)
end
end)
minetest.register_on_shutdown(function()
if playereffects.save then
minetest.log("action", "[playereffects] Server shuts down. Rescuing data into playereffects")
playereffects.save_to_file()
end
minetest.log("action", "[playereffects] Server shuts down. Rescuing data into playereffects")
playereffects.save_to_file()
end)
minetest.register_on_joinplayer(function(player)
local playername = player:get_player_name()
-- load all the effects again (if any)
if (playereffects.inactive_effects[playername] ~= nil) then
for i=1,#playereffects.inactive_effects[playername] do
local effect = playereffects.inactive_effects[playername][i]
playereffects.apply_effect_type(effect.effect_type_id, effect.time_left, player, effect.repeat_interval_time_left)
end
playereffects.inactive_effects[playername] = nil
playereffects.hudinfos[playername] = {}
local inactive_effects = playereffects.inactive_effects[playername]
if inactive_effects ~= nil then
minetest.after(2, function()
for i = 1, #inactive_effects do
local effect = inactive_effects[i]
playereffects.apply_effect_type(effect.effect_type_id, effect.time_left, player, effect.repeat_interval_time_left)
end
end)
end
playereffects.inactive_effects[playername] = {}
end)
-- Autosave into file
if playereffects.use_autosave then
if use_autosave then
minetest.register_globalstep(function(dtime)
playereffects.autosave_timer = playereffects.autosave_timer or 0
playereffects.autosave_timer = playereffects.autosave_timer + dtime
if playereffects.autosave_timer >= playereffects.autosave_time then
if playereffects.autosave_timer >= autosave_time then
playereffects.autosave_timer = 0
minetest.log("action", "[playereffects] Autosaving mod data to playereffects ...")
minetest.log("action", "[playereffects] Autosaving mod data to playereffects...")
playereffects.save_to_file()
end
end)
@ -442,22 +405,24 @@ end)
--[=[ HUD ]=]
function playereffects.hud_update(player)
if (playereffects.use_hud == true) then
if playereffects.use_hud then
local now = os.time()
local playername = player:get_player_name()
local hudinfos = playereffects.hudinfos[playername]
if (hudinfos ~= nil) then
if hudinfos ~= nil then
for effect_id, hudinfo in pairs(hudinfos) do
local effect = playereffects.effects[effect_id]
if (effect ~= nil and hudinfo.text_id ~= nil) then
if effect ~= nil and hudinfo.text_id ~= nil then
local description = playereffects.effect_types[effect.effect_type_id].description
local repeat_interval = playereffects.effect_types[effect.effect_type_id].repeat_interval
if (repeat_interval ~= nil) then
if repeat_interval ~= nil then
local repeat_interval_time_left = os.difftime(effect.repeat_interval_start_time + effect.repeat_interval_time_left, now)
player:hud_change(hudinfo.text_id, "text", description .. " ("..tostring(effect.time_left).."/"..tostring(repeat_interval_time_left) .. " " .. S("s") .. ")")
player:hud_change(hudinfo.text_id, "text",
description .. " (" .. effect.time_left .. " / " .. repeat_interval_time_left .. " " .. S("s") .. ")")
else
local time_left = os.difftime(effect.start_time + effect.time_left, now)
player:hud_change(hudinfo.text_id, "text", description .. " ("..tostring(time_left).. " " .. S("s") .. ")")
player:hud_change(hudinfo.text_id, "text",
description .. " (" .. time_left .. " " .. S("s") .. ")")
end
end
end
@ -466,16 +431,15 @@ function playereffects.hud_update(player)
end
function playereffects.hud_clear(player)
if (playereffects.use_hud == true) then
if playereffects.use_hud then
local playername = player:get_player_name()
local hudinfos = playereffects.hudinfos[playername]
if (hudinfos ~= nil) then
if hudinfos then
for effect_id, hudinfo in pairs(hudinfos) do
local effect = playereffects.effects[effect_id]
if (hudinfo.text_id ~= nil) then
if hudinfo.text_id then
player:hud_remove(hudinfo.text_id)
end
if (hudinfo.icon_id ~= nil) then
if hudinfo.icon_id then
player:hud_remove(hudinfo.icon_id)
end
playereffects.hudinfos[playername][effect_id] = nil
@ -484,49 +448,41 @@ function playereffects.hud_clear(player)
end
end
function playereffects.hud_effect(effect_type_id, player, pos, time_left, repeat_interval_time_left)
function playereffects.hud_effect(effect_type_id, player, pos)
local text_id, icon_id
local effect_type = playereffects.effect_types[effect_type_id]
if (playereffects.use_hud == true and effect_type.hidden == false) then
if playereffects.use_hud and not effect_type.hidden then
local color
if (playereffects.effect_types[effect_type_id].cancel_on_death == true) then
if effect_type.cancel_on_death then
color = 0xFFFFFF
else
color = 0xF0BAFF
end
local description = playereffects.effect_types[effect_type_id].description
local text
if (repeat_interval_time_left ~= nil) then
text = description .. " ("..tostring(time_left).."/"..tostring(repeat_interval_time_left) .. " " .. S("s") .. ")"
else
text = description .. " ("..tostring(time_left).." " .. S("s") .. ")"
end
text_id = player:hud_add({
hud_elem_type = "text",
position = {x = 1, y = 0.3},
name = "effect_"..effect_type_id,
text = text,
name = "effect_" .. effect_type_id,
scale = {x = 170, y = 20},
alignment = {x = -1, y = 0},
direction = 1,
number = color,
offset = {x = -5, y = pos * 30}
})
if (playereffects.effect_types[effect_type_id].icon ~= nil) then
local icon = effect_type.icon
if icon then
icon_id = player:hud_add({
hud_elem_type = "image",
scale = {x = 1, y = 1},
position = { x = 1, y = 0.3 },
name = "effect_icon_"..effect_type_id,
text = playereffects.effect_types[effect_type_id].icon,
position = {x = 1, y = 0.3},
name = "effect_icon_" .. effect_type_id,
text = icon,
alignment = {x = -1, y = 0},
direction = 0,
offset = {x = -230, y = pos * 30},
offset = {x = -230, y = pos * 30}
})
end
else
text_id = nil
icon_id = nil
end
return text_id, icon_id
end

View File

@ -0,0 +1 @@
s=с.

View File

@ -28,8 +28,7 @@ local function update_vessels_shelf(pos)
formspec = formspec ..
"image[" .. vx .. "," .. vy .. ";1,1;vessels_shelf_slot.png]"
else
local vessel = minetest.registered_items[stack:get_name()] or {}
if vessel and vessel.groups and vessel.groups.potion then
if minetest.get_item_group(stack:get_name(), "potion") > 0 then
n_potions = n_potions + stack:get_count()
else
n_empty = n_empty + stack:get_count()
@ -115,22 +114,21 @@ minetest.register_craft({
minetest.register_node("vessels:glass_bottle", {
description = "Empty Glass Bottle",
drawtype = "plantlike",
tiles = {"vessels_glass_bottle.png"},
tiles = {"[combine:32x32:0,2=vessels_glass_bottle.png"},
wield_image = "vessels_glass_bottle.png",
inventory_image = "vessels_glass_bottle.png",
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
fixed = {-0.25, -0.5, -0.25, 0.25, 0.35, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults()
})
minetest.register_alias("potions:glass_bottle", "vessels:glass_bottle")
minetest.register_craft( {
minetest.register_craft({
output = "vessels:glass_bottle 4",
recipe = {
{"", "", ""},