make lingering potions activate target (+ indentation fix)

This commit is contained in:
AFCMS 2022-02-26 22:44:50 +01:00 committed by cora
parent 1a1c592452
commit fb35af4dba
1 changed files with 66 additions and 61 deletions

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname())
local mod_target = minetest.get_modpath("mcl_target")
local function lingering_image(colorstring, opacity)
if not opacity then
opacity = 127
@ -125,11 +127,11 @@ function mcl_potions.register_lingering(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",{
minetest.register_entity(id.."_flying",{
textures = {lingering_image(color)},
hp_max = 1,
visual_size = {x=w/2,y=w/2},
@ -141,6 +143,9 @@ minetest.register_entity(id.."_flying",{
local n = node.name
local g = minetest.get_item_group(n, "liquid")
local d = 4
if mod_target and n == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
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")
@ -161,5 +166,5 @@ minetest.register_entity(id.."_flying",{
self.object:remove()
end
end,
})
})
end