Skip to content

Commit

Permalink
allow collisions with (non-physical) players
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxionary committed Feb 4, 2024
1 parent f2c644c commit 509200a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion api/internal.lua
Expand Up @@ -138,7 +138,11 @@ local function cast_for_collisions(self)
local props = ref:get_properties()
-- TODO collision with source should be an optional parameter
-- TODO non-physical entities should also be an optional parameter (use arrows to pick up remote items!)
if ref ~= self._source_obj and ref ~= obj and props.physical and props.collide_with_objects then
if
ref ~= self._source_obj
and ref ~= obj
and (minetest.is_player(ref) or (props.physical and props.collide_with_objects))
then
return handle_object_collision(self, pointed_thing)
end
elseif pointed_thing.type == "node" then
Expand Down
8 changes: 6 additions & 2 deletions api/math.lua
Expand Up @@ -115,6 +115,7 @@ function ballistics.ballistic_cast(def)
local pos = assert(def.pos, "must specify a starting position")
local objects = futil.coalesce(def.objects, true)
local objects_physical = futil.coalesce(def.objects_physical, true)
local objects_player = futil.coalesce(def.objects_player, true)
local objects_collide_with_objects = futil.coalesce(def.objects_collide_with_objects, true)
local liquids = futil.coalesce(def.liquids, true)
local nodes_walkable = futil.coalesce(def.walkable, true)
Expand All @@ -135,8 +136,11 @@ function ballistics.ballistic_cast(def)
elseif pointed_thing.type == "object" then
local props = pointed_thing.ref:get_properties()
if
((not objects_physical) or props.physical)
and ((not objects_collide_with_objects) or props.collide_with_objects)
(
not objects_physical
or props.physical
or (objects_player and minetest.is_player(pointed_thing.ref))
) and ((not objects_collide_with_objects) or props.collide_with_objects)
then
return pointed_thing
end
Expand Down

0 comments on commit 509200a

Please sign in to comment.