Skip to content

[PR] Add wear calculation #146

@appgurueu

Description

@appgurueu
local wear=0
	local divide=0
	for i=0,5 do
		local add=player:get_inventory({type="detached", name=name.."_armor"}):get_stack("armor",i):get_wear()
		if not (add == 0) then
			divide=divide+1
		end
		wear=wear+add
	end
	formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
	formspec = formspec:gsub("armor_level", armor.def[name].level)
	formspec = formspec:gsub("armor_wear",  100-((math.floor(wear/(divide*65535)*1000+0.5)/10) or "0").."")

BTW, wear bar would be nice too.

Note you also have to change :

armor.formspec = armor.formspec..
	"label[5,1;"..F("Level")..": armor_level]"..
	"label[5,1.5;"..F("Heal")..":  armor_attr_heal]"..
	"label[5,3;"..F("Wear")..":  armor_wear]"

👍 Keep up the good work !!! Great mods !!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions