Skip to content

Commit

Permalink
Update player.lua
Browse files Browse the repository at this point in the history
Add a new setting to auto-trash stone pickaxes when you pick up a better pickaxe
  • Loading branch information
HobbitPower authored Dec 3, 2023
1 parent c76c360 commit b174763
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mods/ctf/ctf_modebase/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ ctf_settings.register("auto_trash_stone_swords", {
default = "false"
})

ctf_settings.register("auto_trash_stone_pickaxes", {
type = "bool",
label = "Auto-trash stone pickaxes when you pick up a better pickaxe",
description = "Only triggers when picking up pickaxes from the ground",
default = "false"
})

local simplify_for_saved_stuff = function(iname)
if not iname or iname == "" then return iname end

Expand Down Expand Up @@ -215,7 +222,12 @@ minetest.register_on_item_pickup(function(itemstack, picker)
inv:set_stack("main", i, itemstack)

if compare:get_name() == "ctf_melee:sword_stone" and
ctf_settings.get(picker, "auto_trash_stone_swords") == "true" then
ctf_settings.get(picker, "auto_trash_stone_swords") == "true" then
return ItemStack("")
end

if compare:get_name() == "default:pick_stone" and
ctf_settings.get(picker, "auto_trash_stone_pickaxes") == "true" then
return ItemStack("")
else
local result = inv:add_item("main", compare):get_count()
Expand All @@ -224,14 +236,12 @@ minetest.register_on_item_pickup(function(itemstack, picker)
return ItemStack("")
else
compare:set_count(result)

return compare
end
end
end
end
end

break -- We already found a place for it, don't check for one held by a different item type
end
end
Expand Down

0 comments on commit b174763

Please sign in to comment.