Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add the player name to dropped items
The player name is now added in the field "dropped_by" on the created
entity.
  • Loading branch information
RobertZenz authored and est31 committed Nov 11, 2015
1 parent 76c9abe commit 0876623
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion builtin/game/item.lua
Expand Up @@ -348,7 +348,7 @@ function core.item_place(itemstack, placer, pointed_thing, param2)
end

function core.item_drop(itemstack, dropper, pos)
if dropper.is_player then
if dropper and dropper:is_player() then

This comment has been minimized.

Copy link
@HybridDog

HybridDog Nov 17, 2015

Contributor

This comment has been minimized.

Copy link
@est31

est31 Nov 17, 2015

Contributor

Yeah, it might cause problems with the fake player of pipeworks. But thats pipework's problem, not ours, so best you talk to @VanessaE about this.

local v = dropper:get_look_dir()
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
local cs = itemstack:get_count()
Expand All @@ -362,6 +362,7 @@ function core.item_drop(itemstack, dropper, pos)
v.y = v.y*2 + 2
v.z = v.z*2
obj:setvelocity(v)
obj:get_luaentity().dropped_by = dropper:get_player_name()
return itemstack
end

Expand Down
4 changes: 3 additions & 1 deletion builtin/game/item_entity.lua
Expand Up @@ -74,7 +74,8 @@ core.register_entity(":__builtin:item", {
return core.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
age = self.age
age = self.age,
dropped_by = self.dropped_by
})
end,

Expand All @@ -89,6 +90,7 @@ core.register_entity(":__builtin:item", {
else
self.age = dtime_s
end
self.dropped_by = data.dropped_by
end
else
self.itemstring = staticdata
Expand Down

0 comments on commit 0876623

Please sign in to comment.