Fix consume_wield on tools
It shouldn't consume the whole tool, but should wear it. Without having groups to use, just wear the tool based on whichever group is most "lenient" in terms of uses.
This commit is contained in:
parent
ed74795e3f
commit
fa86f42e21
@ -32,6 +32,9 @@ ISSUES-GAME: Gameplay-affecting issues
|
|||||||
- Maybe add a generic "# hints completed" qualifier?
|
- Maybe add a generic "# hints completed" qualifier?
|
||||||
- Maybe add a number of hours played (non-idle) qualifier?
|
- Maybe add a number of hours played (non-idle) qualifier?
|
||||||
|
|
||||||
|
- Stylus is probably worth hiding too until player has
|
||||||
|
made pliant concrete.
|
||||||
|
|
||||||
- All flora should be radiation-sensitive.
|
- All flora should be radiation-sensitive.
|
||||||
- Currently only flowers, add sedges and rushes
|
- Currently only flowers, add sedges and rushes
|
||||||
- Should be at risk of harm during growth or spreading
|
- Should be at risk of harm during growth or spreading
|
||||||
|
@ -229,15 +229,28 @@ end
|
|||||||
|
|
||||||
function nodecore.consume_wield(player, qty)
|
function nodecore.consume_wield(player, qty)
|
||||||
local wielded = player:get_wielded_item()
|
local wielded = player:get_wielded_item()
|
||||||
if wielded then
|
if wielded and qty and qty > 0 then
|
||||||
local wdef = wielded:get_definition()
|
local wdef = wielded:get_definition()
|
||||||
if wdef.stack_max > 1 and qty then
|
if wdef and wdef.stack_max > 1 then
|
||||||
local have = wielded:get_count() - qty
|
local have = wielded:get_count() - qty
|
||||||
if have <= 0 then
|
if have <= 0 then
|
||||||
wielded = ItemStack("")
|
wielded = ItemStack("")
|
||||||
else
|
else
|
||||||
wielded:set_count(have)
|
wielded:set_count(have)
|
||||||
end
|
end
|
||||||
|
elseif wdef and wdef.type == "tool" then
|
||||||
|
local uses = 1
|
||||||
|
local caps = wielded:get_tool_capabilities()
|
||||||
|
for _, v in pairs(caps and caps.groupcaps or {}) do
|
||||||
|
if v.uses > uses then uses = v.uses end
|
||||||
|
end
|
||||||
|
local wear = wielded:get_wear()
|
||||||
|
wear = wear + (65535 / uses) * (1 + nodecore.boxmuller() * 0.05)
|
||||||
|
if wear > 65536 then
|
||||||
|
wielded = ItemStack("")
|
||||||
|
else
|
||||||
|
wielded:set_wear(wear)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return player:set_wielded_item(wielded)
|
return player:set_wielded_item(wielded)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user