Skip to content

Commit

Permalink
Update upgrades on inventory move (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwissalpS authored and OgelGames committed Feb 14, 2022
1 parent 9e0f6ea commit 631879b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions engines/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,29 @@ minetest.register_node("jumpdrive:engine", {
end,

-- inventory protection
allow_metadata_inventory_move = function(pos, _, _, _, _, count, player)
if (not player)
or (not player:is_player())
or minetest.is_protected(pos, player:get_player_name())
then return 0 end

return count
end,

allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if player and player:is_player() and minetest.is_protected(pos, player:get_player_name()) then
-- protected
return 0
end
if (not player)
or (not player:is_player())
or minetest.is_protected(pos, player:get_player_name())
then return 0 end

return stack:get_count()
end,

allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if player and player:is_player() and minetest.is_protected(pos, player:get_player_name()) then
-- protected
return 0
end
if (not player)
or (not player:is_player())
or minetest.is_protected(pos, player:get_player_name())
then return 0 end

return stack:get_count()
end,
Expand All @@ -235,6 +244,12 @@ minetest.register_node("jumpdrive:engine", {
end
end,

on_metadata_inventory_move = function(pos, from_list, _, to_list)
if from_list == "upgrade" or to_list == "upgrade" then
jumpdrive.upgrade.calculate(pos)
end
end,

on_punch = function(pos, node, puncher)

if minetest.is_protected(pos, puncher:get_player_name()) then
Expand Down

0 comments on commit 631879b

Please sign in to comment.