1. #1
    Deleted

    How do I do this in LUA or via another addon?

    Hi, I'm just trying to make a couple of modifications to the Align mod so it behaves like I want it to. Align basically puts a grid on your screen so you can more accurately move bits of the ui around

    Here is a screenshot:



    Just wondering if either anyone who knows lua might be able to suggest modifications to the code or if someone can suggest an alternative addon to do what I would want it to, thx.

    1) only make the red line show up i.e. the huge crosshair centred on your character

    2) modify the width of the red line and the height

    3) only make the top of the four red lines appear

    Thx for help.

    Here is the entirety of the code:




    local grid
    local boxSize = 32

    function Grid_Show()
    if not grid then
    Grid_Create()
    elseif grid.boxSize ~= boxSize then
    grid:Hide()
    Grid_Create()
    else
    grid:Show()
    end
    end

    function Grid_Hide()
    if grid then
    grid:Hide()
    end
    end

    local isAligning = false
    SLASH_TOGGLEGRID1 = "/align"
    SlashCmdList["TOGGLEGRID"] = function(arg)
    if isAligning then
    Grid_Hide()
    isAligning = false
    else
    boxSize = (math.ceil((tonumber(arg) or boxSize) / 32) * 32)
    if boxSize > 256 then boxSize = 256 end
    Grid_Show()
    isAligning = true
    end
    end

    function Grid_Create()
    grid = CreateFrame('Frame', nil, UIParent)
    grid.boxSize = boxSize
    grid:SetAllPoints(UIParent)

    local size = 2
    local width = GetScreenWidth()
    local ratio = width / GetScreenHeight()
    local height = GetScreenHeight() * ratio

    local wStep = width / boxSize
    local hStep = height / boxSize

    for i = 0, boxSize do
    local tx = grid:CreateTexture(nil, 'BACKGROUND')
    if i == boxSize / 2 then
    tx:SetTexture(1, 0, 0, 0.5)
    else
    tx:SetTexture(0, 0, 0, 0.5)
    end
    tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0)
    tx:SetPoint('BOTTOMRIGHT', grid, 'BOTTOMLEFT', i*wStep + (size/2), 0)
    end
    height = GetScreenHeight()

    do
    local tx = grid:CreateTexture(nil, 'BACKGROUND')
    tx:SetTexture(1, 0, 0, 0.5)
    tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2) + (size/2))
    tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2 + size/2))
    end

    for i = 1, math.floor((height/2)/hStep) do
    local tx = grid:CreateTexture(nil, 'BACKGROUND')
    tx:SetTexture(0, 0, 0, 0.5)

    tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2+i*hStep) + (size/2))
    tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2+i*hStep + size/2))

    tx = grid:CreateTexture(nil, 'BACKGROUND')
    tx:SetTexture(0, 0, 0, 0.5)

    tx:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, -(height/2-i*hStep) + (size/2))
    tx:SetPoint('BOTTOMRIGHT', grid, 'TOPRIGHT', 0, -(height/2-i*hStep + size/2))

    end

    end

  2. #2
    Here's my simple rewrite for a basic crosshair in the center of the screen that you can size.

    This is drycoded (not tested) should you get any issues, I'm sure Treeston could help:
    https://dl.dropboxusercontent.com/u/...nterScreen.zip

    Simply type /crosshair 'thickness' and you'll create a crosshair of your desired thickness in the center of the screen.

    Code:
    local crosshair
    local thickness = 4
    
    
    function crosshair_Show()
    	if not crosshair then
            crosshair_Create()
    	elseif crosshair.thickness ~= thickness then
            crosshair:Hide()
            crosshair_Create()
        else
    		crosshair:Show()
    	end
    end
    
    
    function crosshair_Hide()
    	if crosshair then
    		crosshair:Hide()
    	end
    end
    
    
    local isCrossing = false
    SLASH_TOGGLECROSSHAIR1 = "/crosshair"
    SlashCmdList["TOGGLECROSSHAIR"] = function(arg)
        if isCrossing then
            crosshair_Hide()
            isCrossing = false
        else
            thickness = tonumber(arg)
    		crosshair_Show()
    		isCrossing = true
    	end
    end
    
    
    function crosshair_Create() 
    	crosshair = CreateFrame('Frame', nil, UIParent) 
    	crosshair.thickness = thickness 
    	crosshair:SetAllPoints(UIParent) 
    
    
    	local scale = UIParent:GetEffectiveScale()
    	local width = GetScreenWidth()*scale
    	local height = GetScreenHeight()*scale
    	
    	local centerX = width/2
    	local centerY = height/2
    
    
    	local v = crosshair:CreateTexture(nil, 'BACKGROUND')
    	v:SetTexture(1,0,0,0.5)
    	v:SetPoint("TOPLEFT", crosshair, "TOPLEFT", (centerX-(thickness/2)), 0)
    	v:SetPoint('BOTTOMRIGHT', crosshair, 'BOTTOMLEFT', (centerX+(thickness/2)), 0)
    	
    	local h = crosshair:CreateTexture(nil, 'BACKGROUND')
    	h:SetTexture(1,0,0,0.5)
    	h:SetPoint("TOPLEFT", crosshair, "TOPLEFT", 0,(centerY+(thickness/2)))
    	h:SetPoint('BOTTOMRIGHT', crosshair, 'TOPRIGHT', 0, (centerY-(thickness/2)))
    	
    end

  3. #3
    Deleted
    Those leaked global functions make me sad

    - - - Updated - - -

    Also, I believe the OP only wanted the top line (the one from the top to the center of the screen) to appear.

    Drycoded:
    Code:
    local crosshair
    
    SlashCmdList["CROSSHAIR"] = function(c)
        local size = tonumber(c)
        if not size then print("Please use: /crosshair |cffff0000<size>|r") return end
        if crosshair and crosshair:IsShown() then
            crosshair:Hide()
            return
        end
        if not crosshair then
            crosshair = CreateFrame("Frame",nil,UIParent)
            crosshair:SetFrameStrata("TOOLTIP")
            crosshair:SetPoint("TOP")
            crosshair:SetPoint("BOTTOM",UIParent,"CENTER")
            crosshair:Hide()
            crosshair.tex = crosshair:CreateTexture(nil,"ARTWORK")
            crosshair.tex:SetAllPoints()
            crosshair.tex:SetTexture(1,0,0)
        end
        crosshair:SetWidth(size)
        crosshair:Show()
    end
    SLASH_CROSSHAIR1 = "/crosshair"

  4. #4
    Deleted
    Thank you very, very much both of you Syronius and Treeston!

    Yes I actually did just want a red line coming out from my character to the top of the screen that was slightly fatter than the current one.

    Before I read your responses I actually ended up kind of figuring it out (I don't know a word of LUA :S) just by deleting and changing random numbers and lines from that mod until it worked. Good old fashioned trial and error!

    This is what I got, but yours is a lot cleaner! You mentioned leaked global functions and I have a feeling this is full of them! But just posting for reference.

    Thx again!

    Code:
    local grid
    local boxSize = 8
    
    function Grid_Show()
    	if not grid then
            Grid_Create()
        else
    		grid:Show()
    	end
    end
    
    function Grid_Hide()
    	if grid then
    		grid:Hide()
    	end
    end
    
    local isAligning = false
    SLASH_TOGGLEGRID1 = "/align"
    SlashCmdList["TOGGLEGRID"] = function(arg)
        if isAligning then
            Grid_Hide()
            isAligning = false
        else
            boxSize = (math.ceil((tonumber(arg) or boxSize) / 32) * 32)
        if boxSize > 256 then boxSize = 256 end    
            Grid_Show()
            isAligning = true
        end
    end
    
    function Grid_Create() 
    	grid = CreateFrame('Frame', nil, UIParent) 
    	grid.boxSize = boxSize 
    	grid:SetAllPoints(UIParent) 
    
    	local size = 10 
    	local width = GetScreenWidth()
    	local ratio = width / GetScreenHeight()
    	local height = GetScreenHeight() * ratio
    
    	local wStep = width / boxSize
    	local hStep = height / boxSize
    
    	for i = 0, boxSize do 
    		local tx = grid:CreateTexture(nil, 'BACKGROUND') 
    		if i == boxSize / 2 then 
    			tx:SetTexture(1, 0, 0, 0.5) 
    		else 
    
    		end 
    		tx:SetPoint("TOPLEFT", grid, "TOPLEFT", i*wStep - (size/2), 0) 
    		tx:SetPoint('BOTTOMRIGHT', grid, 'BOTTOMLEFT', i*wStep + (size/2), 410) 
    	end 
    	height = GetScreenHeight()
    	
    	do
    
    	end
    	
    	for i = 1, math.floor((height/2)/hStep) do
    
    	end
    	
    end

Posting Permissions

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