mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-25 02:42:25 +01:00
Fix indentations in mcl_potions/mcl_brewing
This commit is contained in:
parent
7104bbd2df
commit
a472c30163
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user