1. #1

    Looking for code to resize nameplates

    What I am NOT interested in is downloading an addon. Please do not suggest one.

    All I'm looking for is a way to resize the default nameplates with a script.

    Normally this is as easy as doing something like "PlayerFrame:SetScale(1.0)" but with nameplates, there are hundreds of them (right now on my screen NamePlate561 exists) and they are constantly being renumbered. The frame name in Fstack is called "NamePlate#", so when you do /script NamePlate1:SetScale(1.0) it works, as long as #1 exists and is on-screen. Problem is the renumbering, so I can't simply put thousands of lines of code for this.

    I've tried various for loops, but my programming knowledge is barely script kiddie level. Help is appreciated.

  2. #2
    Quote Originally Posted by Mozu View Post
    What I am NOT interested in is downloading an addon. Please do not suggest one.

    All I'm looking for is a way to resize the default nameplates with a script.

    Normally this is as easy as doing something like "PlayerFrame:SetScale(1.0)" but with nameplates, there are hundreds of them (right now on my screen NamePlate561 exists) and they are constantly being renumbered. The frame name in Fstack is called "NamePlate#", so when you do /script NamePlate1:SetScale(1.0) it works, as long as #1 exists and is on-screen. Problem is the renumbering, so I can't simply put thousands of lines of code for this.

    I've tried various for loops, but my programming knowledge is barely script kiddie level. Help is appreciated.
    You cannot rescale the nameplates hitbox (the area that you click) while in combat. Nameplates are secure. Your code NamePlate1:SetScale() would not work while in combat.

    You can however rescale the healthbar and castbar when they show but the textures still don't scale properly. I ripped this code from my addon it will be a start for you.

    Code:
    local numChildren = -1
    local handledFrames = {}
    local HEALTH_SCALE, CASTBAR_SCALE = 1, 1
    local function HealthBar_OnShow(frame)
    	frame:SetScale(HEALTH_SCALE)
    end
    
    local function CastBar_OnShow(frame)
    	frame:SetScale(CASTBAR_SCALE)
    end
    
    local function manageFrame(frame)
    	local hp, cb = frame:GetChildren()
    	
    	for i=1, frame:GetNumRegions() do
    		local region = select(i, frame:GetRegions())
    		if region then
    			region:SetParent(hp)
    		end
    	end	
    
    	if not frame.healthBar then
    		hp:HookScript("OnShow", HealthBar_OnShow)
    		frame.healthBar = hp
    	end
    	
    	if not frame.castBar then
    		cb:HookScript("OnShow", CastBar_OnShow)
    		frame.castBar = cb	
    	end
    	
    	HealthBar_OnShow(hp)
    	CastBar_OnShow(cb)
    end
    
    local function HookFrames(...)
    	for index = 1, select('#', ...) do
    		local frame = select(index, ...)
    		local name = frame:GetName()
    		
    		if name and (not handledFrames[name] and (name:find("NamePlate%d"))) then
    			manageFrame(frame:GetChildren())
    			handledFrames[name] = frame
    		end
    	end
    end
    
    local f = CreateFrame("Frame")
    f:SetScript("OnUpdate", function(self, elapsed)
    	local count = WorldFrame:GetNumChildren()
    	if(count ~= numChildren) then
    		numChildren = count
    		HookFrames(WorldFrame:GetChildren())
    	end	
    end)
    All healthbar regions are parented to the healthbar's parent. You can try to reparent them to the healthbar to see if that will correct the scale. Otherwise you may have to create duplicate textures/fontstrings for the healthbar and remove the default blizzard ones.
    Last edited by Elv; 2013-02-12 at 08:01 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •