511455fff9
- Thrown objects inherit initial velocity. - Player and objects have matched terminal velocity and can free-fall in tandem. - Thrown objects experience horizontal air friction too.
31 lines
783 B
Lua
31 lines
783 B
Lua
-- LUALOCALS < ---------------------------------------------------------
|
|
local minetest
|
|
= minetest
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
local item_last_added
|
|
|
|
local old_add = minetest.add_item
|
|
function minetest.add_item(...)
|
|
local function helper(obj, ...)
|
|
item_last_added = obj
|
|
return obj, ...
|
|
end
|
|
return helper(old_add(...))
|
|
end
|
|
|
|
local old_drop = minetest.item_drop
|
|
function minetest.item_drop(itemstack, dropper, ...)
|
|
if not dropper or not dropper:is_player() then
|
|
return old_drop(itemstack, dropper, ...)
|
|
end
|
|
local function helper(...)
|
|
if item_last_added then
|
|
item_last_added:add_velocity(dropper:get_player_velocity())
|
|
end
|
|
return ...
|
|
end
|
|
item_last_added = nil
|
|
return helper(old_drop(itemstack, dropper, ...))
|
|
end
|