mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-04 15:21:06 +01:00
Add remaining use of a tool/weapon in tooltips
This commit is contained in:
parent
81ca224bb8
commit
c501ff6e1d
14 changed files with 48 additions and 26 deletions
|
@ -534,6 +534,7 @@ end
|
|||
function mcl_util.use_item_durability(itemstack, n)
|
||||
local uses = mcl_util.calculate_durability(itemstack)
|
||||
itemstack:add_wear(65535 / uses * n)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
|
||||
function mcl_util.deal_damage(target, damage, mcl_reason)
|
||||
|
|
|
@ -448,6 +448,7 @@ function minetest.node_dig(pos, node, digger)
|
|||
end
|
||||
end
|
||||
end
|
||||
tt.reload_itemstack_description(wielded) -- update tooltip
|
||||
digger:set_wielded_item(wielded)
|
||||
end
|
||||
|
||||
|
|
|
@ -646,6 +646,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
|
|||
if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then
|
||||
local wear = math.floor(65535/tool_capabilities.punch_attack_uses)
|
||||
weapon:add_wear(wear)
|
||||
tt.reload_itemstack_description(weapon) -- update tooltip
|
||||
hitter:set_wielded_item(weapon)
|
||||
end
|
||||
end, hitter:get_player_name())
|
||||
|
|
|
@ -122,6 +122,7 @@ mooshroom_def.on_rightclick = function(self, clicker)
|
|||
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
item:add_wear(mobs_mc.shears_wear)
|
||||
tt.reload_itemstack_description(item) -- update tooltip
|
||||
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
||||
end
|
||||
-- Use bucket to milk
|
||||
|
|
|
@ -249,6 +249,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", {
|
|||
})
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
item:add_wear(mobs_mc.shears_wear)
|
||||
tt.reload_itemstack_description(item) -- update tooltip
|
||||
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
||||
end
|
||||
return
|
||||
|
|
|
@ -131,6 +131,7 @@ mcl_mobs.register_mob("mobs_mc:snowman", {
|
|||
-- Wear out
|
||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||
item:add_wear(mobs_mc.shears_wear)
|
||||
tt.reload_itemstack_description(item) -- update tooltip
|
||||
clicker:get_inventory():set_stack("main", clicker:get_wield_index(), item)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ local function newline(str)
|
|||
end
|
||||
|
||||
-- Digging capabilities of tool
|
||||
tt.register_snippet(function(itemstring, toolcaps)
|
||||
tt.register_snippet(function(itemstring, toolcaps, itemstack)
|
||||
local def = minetest.registered_items[itemstring]
|
||||
if not toolcaps then
|
||||
return
|
||||
|
@ -85,7 +85,12 @@ tt.register_snippet(function(itemstring, toolcaps)
|
|||
if def._doc_items_durability == nil and base_uses > 0 then
|
||||
local real_uses = base_uses * math.pow(3, maxlevel)
|
||||
if real_uses < 65535 then
|
||||
miningusesstr = S("@1 uses", real_uses)
|
||||
if itemstack then
|
||||
local remaining_uses = math.round(real_uses - (itemstack:get_wear() * base_uses) / 65535)
|
||||
miningusesstr = remaining_uses .. "/" .. real_uses
|
||||
else
|
||||
miningusesstr = S("@1 uses", real_uses)
|
||||
end
|
||||
else
|
||||
miningusesstr = S("Unlimited uses")
|
||||
end
|
||||
|
|
|
@ -227,6 +227,7 @@ local dispenserdef = {
|
|||
entity.gotten = true
|
||||
minetest.sound_play("mcl_tools_shears_cut", { pos = pos }, true)
|
||||
stack:add_wear(65535 / stackdef._mcl_diggroups.shearsy.uses)
|
||||
tt.reload_itemstack_description(stack) -- update tooltip
|
||||
inv:set_stack("main", stack_id, stack)
|
||||
break
|
||||
end
|
||||
|
|
|
@ -300,6 +300,7 @@ controls.register_on_release(function(player, key, time)
|
|||
durability = durability * (unbreaking + 1)
|
||||
end
|
||||
wielditem:add_wear(65535/durability)
|
||||
tt.reload_itemstack_description(wielditem) -- update tooltip
|
||||
end
|
||||
player:set_wielded_item(wielditem)
|
||||
reset_bow_state(player, true)
|
||||
|
|
|
@ -350,6 +350,7 @@ controls.register_on_press(function(player, key, time)
|
|||
durability = durability / 3
|
||||
end
|
||||
wielditem:add_wear(65535/durability)
|
||||
tt.reload_itemstack_description(wielditem) -- update tooltip
|
||||
end
|
||||
player:set_wielded_item(wielditem)
|
||||
reset_bow_state(player, true)
|
||||
|
|
|
@ -323,6 +323,7 @@ function mcl_campfires.register_campfire(name, def)
|
|||
local wear = mcl_autogroup.get_wear(toolname, "shovely")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
end
|
||||
node.name = name
|
||||
|
|
|
@ -43,6 +43,7 @@ local hoe_on_place_function = function(wear_divisor)
|
|||
if create_soil(pointed_thing.under, user:get_inventory()) then
|
||||
if not minetest.is_creative_enabled(user:get_player_name()) then
|
||||
itemstack:add_wear(65535/wear_divisor)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
|
|
@ -140,6 +140,7 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||
local idef = itemstack:get_definition()
|
||||
itemstack:add_wear(65535/durability) -- 65 uses
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then
|
||||
minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true)
|
||||
end
|
||||
|
@ -154,6 +155,7 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||
local idef = itemstack:get_definition()
|
||||
itemstack:add_wear((65535/durability)*2) -- if so and not creative then wear double like in MC.
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then
|
||||
minetest.sound_play(idef.sound.breaks, {pos=player:get_pos(), gain=0.5}, true)
|
||||
end
|
||||
|
|
|
@ -186,6 +186,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
|
|||
local wear = mcl_autogroup.get_wear(toolname, "shovely")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
end
|
||||
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above, max_hear_distance = 16}, true)
|
||||
|
@ -209,6 +210,7 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
|
|||
local wear = mcl_autogroup.get_wear(toolname, "shovely")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
end
|
||||
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above, max_hear_distance = 16}, true)
|
||||
|
@ -240,6 +242,7 @@ if minetest.get_modpath("mcl_farming") then
|
|||
local wear = mcl_autogroup.get_wear(toolname, "shearsy")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -420,6 +423,7 @@ local function make_stripped_trunk(itemstack, placer, pointed_thing)
|
|||
local wear = mcl_autogroup.get_wear(toolname, "axey")
|
||||
if wear then
|
||||
itemstack:add_wear(wear)
|
||||
tt.reload_itemstack_description(itemstack) -- update tooltip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue