aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/item.lua3
-rw-r--r--builtin/game/item_entity.lua4
2 files changed, 5 insertions, 2 deletions
diff --git a/builtin/game/item.lua b/builtin/game/item.lua
index df5bb070d..44ec35cc9 100644
--- a/builtin/game/item.lua
+++ b/builtin/game/item.lua
@@ -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
local v = dropper:get_look_dir()
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
local cs = itemstack:get_count()
@@ -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
diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua
index a8d7a1863..be158c119 100644
--- a/builtin/game/item_entity.lua
+++ b/builtin/game/item_entity.lua
@@ -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,
@@ -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
n> "client" .. DIR_DELIM local commonpath = scriptdir .. "common" .. DIR_DELIM local asyncpath = scriptdir .. "async" .. DIR_DELIM dofile(commonpath .. "strict.lua") dofile(commonpath .. "serialize.lua") dofile(commonpath .. "misc_helpers.lua") if INIT == "game" then dofile(gamepath .. "init.lua") assert(not core.get_http_api) elseif INIT == "mainmenu" then local mm_script = core.settings:get("main_menu_script") if mm_script and mm_script ~= "" then dofile(mm_script) else dofile(core.get_mainmenu_path() .. DIR_DELIM .. "init.lua") end elseif INIT == "async" then dofile(asyncpath .. "init.lua") elseif INIT == "client" then dofile(clientpath .. "init.lua") else error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) end