Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Add wear calculation #146

Open
appgurueu opened this issue Jun 15, 2018 · 0 comments
Open

[PR] Add wear calculation #146

appgurueu opened this issue Jun 15, 2018 · 0 comments
Labels

Comments

@appgurueu
Copy link

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 !!!

AntumDeluge pushed a commit to AntumMT/mp-3d_armor-old that referenced this issue Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants