Correct issues with splash potions disappearing immediately when thrown.

This commit is contained in:
Brandon 2020-06-17 17:36:15 -04:00
parent b8256cd447
commit 454a9c231e

@ -11,7 +11,7 @@ local function register_splash(name, descr, color, def)
minetest.register_craftitem(id, { minetest.register_craftitem(id, {
description = descr, description = descr,
inventory_image = splash_image(color), inventory_image = splash_image(color),
on_use = function(itemstack, placer, pointed_thing) on_use = function(item, placer, pointed_thing)
--weapons_shot(itemstack, placer, pointed_thing, def.velocity, name) --weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
local velocity = 10 local velocity = 10
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
@ -19,8 +19,8 @@ local function register_splash(name, descr, color, def)
local obj = minetest.env:add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") local obj = minetest.env: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:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
obj:setacceleration({x=0, y=-9.8, z=0}) obj:setacceleration({x=0, y=-9.8, z=0})
itemstack:take_item() item:take_item()
return itemstack return item
end, end,
stack_max = 1, stack_max = 1,
}) })
@ -31,7 +31,7 @@ local function register_splash(name, descr, color, def)
textures = {splash_image(color)}, textures = {splash_image(color)},
hp_max = 1, hp_max = 1,
visual_size = {x=w/2,y=w/2}, visual_size = {x=w/2,y=w/2},
collisionbox = {-w,-w,-w,w,w,w}, collisionbox = {0,0,0,0,0,0},
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
@ -65,10 +65,10 @@ local function register_splash(name, descr, color, def)
pos2 = obj:get_pos() 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)) 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 if rad > 0 then def.potion_fun(obj, redux_map[rad]) else def.potion_fun(obj, 1) end
print(obj:get_player_name().." "..math.floor(rad))
end end
end end
end end
end, end,
}) })