mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-26 09:40:28 +01:00
Move minetest.rotate_node() edit to [_misc]
DON'T edit mods directly if it's possible to override them, or if
the edit has no relation to that specific mod (which was the case).
This reverts commit 3752bf2e64
.
This commit is contained in:
parent
2394483dc9
commit
947b301456
@ -534,27 +534,3 @@ function default.intersects_protection(minp, maxp, player_name, interval)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--rewrite function minetest.rotate_node(itemstack, placer, pointed_thing) to refill inventory
|
||||
local old_rotate_node = minetest.rotate_node
|
||||
function minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||
local stack_name = itemstack:get_name()
|
||||
local ret = old_rotate_node(itemstack, placer, pointed_thing)
|
||||
if ret:get_count() == 0 and not minetest.setting_getbool("creative_mode") then
|
||||
local index = placer:get_wield_index()
|
||||
local inv = placer:get_inventory()
|
||||
if inv:get_list("main") then
|
||||
for i, stack in ipairs(inv:get_list("main")) do
|
||||
if i ~= index and stack:get_name() == stack_name then
|
||||
ret:add_item(stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
minetest.log("action", "Inventory Tweaks: refilled stack("..stack_name..") of " .. placer:get_player_name())
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
@ -9,6 +9,10 @@ dofile(cwd.."/carbone_init.lua")
|
||||
dofile(cwd.."/commands.lua")
|
||||
dofile(cwd.."/forbid_underwater_torch.lua")
|
||||
|
||||
-- Inventory refill function override
|
||||
-- see https://github.com/MinetestForFun/server-minetestforfun/issues/462
|
||||
dofile(cwd.."/inventory_rotate_node.lua")
|
||||
|
||||
-- Give initial stuff
|
||||
dofile(cwd.."/give_initial_stuff.lua")
|
||||
|
||||
|
22
mods/_misc/inventory_rotate_node.lua
Normal file
22
mods/_misc/inventory_rotate_node.lua
Normal file
@ -0,0 +1,22 @@
|
||||
--rewrite function minetest.rotate_node(itemstack, placer, pointed_thing) to refill inventory
|
||||
local old_rotate_node = minetest.rotate_node
|
||||
function minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||
local stack_name = itemstack:get_name()
|
||||
local ret = old_rotate_node(itemstack, placer, pointed_thing)
|
||||
if ret:get_count() == 0 and not minetest.setting_getbool("creative_mode") then
|
||||
local index = placer:get_wield_index()
|
||||
local inv = placer:get_inventory()
|
||||
if inv:get_list("main") then
|
||||
for i, stack in ipairs(inv:get_list("main")) do
|
||||
if i ~= index and stack:get_name() == stack_name then
|
||||
ret:add_item(stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
minetest.log("action", "Inventory Tweaks: refilled stack("..stack_name..") of " .. placer:get_player_name())
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
Loading…
Reference in New Issue
Block a user