Skip to content

Commit 0876623

Browse files
RobertZenzest31
authored andcommittedNov 11, 2015
Add the player name to dropped items
The player name is now added in the field "dropped_by" on the created entity.
1 parent 76c9abe commit 0876623

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

Diff for: ‎builtin/game/item.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function core.item_place(itemstack, placer, pointed_thing, param2)
348348
end
349349

350350
function core.item_drop(itemstack, dropper, pos)
351-
if dropper.is_player then
351+
if dropper and dropper:is_player() then
Has conversations. Original line has conversations.
352352
local v = dropper:get_look_dir()
353353
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
354354
local cs = itemstack:get_count()
@@ -362,6 +362,7 @@ function core.item_drop(itemstack, dropper, pos)
362362
v.y = v.y*2 + 2
363363
v.z = v.z*2
364364
obj:setvelocity(v)
365+
obj:get_luaentity().dropped_by = dropper:get_player_name()
365366
return itemstack
366367
end
367368

Diff for: ‎builtin/game/item_entity.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ core.register_entity(":__builtin:item", {
7474
return core.serialize({
7575
itemstring = self.itemstring,
7676
always_collect = self.always_collect,
77-
age = self.age
77+
age = self.age,
78+
dropped_by = self.dropped_by
7879
})
7980
end,
8081

@@ -89,6 +90,7 @@ core.register_entity(":__builtin:item", {
8990
else
9091
self.age = dtime_s
9192
end
93+
self.dropped_by = data.dropped_by
9294
end
9395
else
9496
self.itemstring = staticdata

0 commit comments

Comments
 (0)
Please sign in to comment.