Help by Lua Code menu

User Tag List

Results 1 to 3 of 3
  1. #1
    alic's Avatar Member
    Reputation
    2
    Join Date
    Mar 2025
    Posts
    9
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help by Lua Code

    I don't know if I'm in the right place here. I have the code from Mazer in the forum. He made it available to us. Thank you very much. I don't know much about it. I've been working on it for 5 days now to adapt the code so that it works with Hekili instead of Conro. Is there anyone here who could help me and has some knowledge about it?

    Code:
    -- =====================================================================
    -- This script creates a color indicator frame in World of Warcraft
    -- It reads text from ConROWindow and changes colors based on the number displayed
    -- The frame changes to white during casting, channeling, or when GCD is active
    -- =====================================================================
    
    
    -- Clean up any existing frame to prevent duplicates
    if ColorFrame then
       ColorFrame:Hide()
       ColorFrame:ClearAllPoints()
       ColorFrame:SetParent(nil)
       ColorFrame = nil
    end
    
    
    -- Define color mapping array
    -- Each entry contains RGB values (red, green, blue) from 0 to 1
    -- Index corresponds to the number displayed in ConROWindow (0-9)
    local colors = {
       {1, 0, 0},    -- 0: Red
       {0, 1, 0},    -- 1: Green
       {0, 0, 1},    -- 2: Blue
       {1, 1, 0},    -- 3: Yellow
       {1, 0, 1},    -- 4: Magenta
       {0, 1, 1},    -- 5: Cyan
       {0.5, 0.5, 0.5}, -- 6: Gray
       {1, 0.5, 0},  -- 7: Orange
       {0, 1, 0.5},  -- 8: Turquoise
       {0.5, 0, 1}   -- 9: Purple
    }
    
    
    -- Create the main frame
    -- Attaches to WorldFrame to ensure it's always visible
    -- Uses BackdropTemplate for visual debugging
    local f = CreateFrame("Frame", "ColorFrame", WorldFrame, "BackdropTemplate")
    f:SetHeight(1)
    f:SetWidth(1)
    f:SetPoint("TOPLEFT", WorldFrame, "TOPLEFT", 0, 0)  -- Position at top-left corner
    f:SetIgnoreParentScale(true)  -- Prevent inheritance of parent's scaling
    f:SetScale(1)
    
    
    -- Create and setup the texture for the frame
    -- Uses a white 8x8 texture as base which will be colored
    local t = f:CreateTexture(nil, "ARTWORK")
    t:SetTexture("Interface\\BUTTONS\\WHITE8X8")
    t:SetTexCoord(0.07, 0.93, 0.07, 0.93)  -- Adjust texture coordinates to prevent bleeding
    t:SetAllPoints(f)  -- Make texture fill the entire frame
    t:SetVertexColor(1, 1, 1, 1)  -- Start with white color
    f.texture = t
    
    
    -- Add a debug backdrop to make frame visible during development
    -- Creates a black semi-transparent background with a black border
    f:SetBackdrop({
          bgFile = "Interface\\Buttons\\WHITE8X8",
          edgeFile = "Interface\\Buttons\\WHITE8X8",
          edgeSize = 1,
    })
    f:SetBackdropColor(0, 0, 0, 0.5)  -- Semi-transparent black background
    f:SetBackdropBorderColor(0, 0, 0, 1)  -- Solid black border
    
    
    -- Update timing configuration
    local updateInterval = 0.1  -- Check for updates every 0.1 seconds
    local timeSinceLastUpdate = 0
    
    
    -- Function to check if Global Cooldown (GCD) is active
    -- Uses spell ID 61304 which represents the global cooldown
    local function IsGCDActive()
        local spellCooldownInfo = C_Spell.GetSpellCooldown(61304)
        if spellCooldownInfo.startTime == 0 then return false end
        return (spellCooldownInfo.startTime + spellCooldownInfo.duration - GetTime()) > 0
    end
    
    
    -- Main update function that runs on every frame
    f:SetScript("OnUpdate", function(self, elapsed)
          timeSinceLastUpdate = timeSinceLastUpdate + elapsed
          
          -- Only update at specified interval to reduce performance impact
          if timeSinceLastUpdate >= updateInterval then
             timeSinceLastUpdate = 0
             
             -- Check player state (casting, channeling, GCD)
             local casting = UnitCastingInfo("player") ~= nil
             local channeling = UnitChannelInfo("player") ~= nil
             local gcdActive = IsGCDActive()
             
             -- Set color to white if player is casting, channeling, or GCD is active
             if casting or channeling or gcdActive then
                t:SetVertexColor(1, 1, 1, 1)
                return
             end
             
             -- Color logic when player is not casting and GCD is not active
             -- Reads number from ConROWindow and sets corresponding color
             if ConROWindow and ConROWindow.fontkey and ConROWindow.fontkey:IsVisible() then
                local text = ConROWindow.fontkey:GetText()
                if text then
                   local number = tonumber(text)
                   if number and colors[number + 1] then
                      -- Set color from our color mapping array
                      local r, g, b = unpack(colors[number + 1])
                      t:SetVertexColor(r, g, b, 1)
                   else
                      -- Default to white if number is invalid
                      t:SetVertexColor(1, 1, 1, 1)
                   end
                else
                   -- Default to white if no text
                   t:SetVertexColor(1, 1, 1, 1)
                end
             else
                -- Default to white if ConROWindow is not visible
                t:SetVertexColor(1, 1, 1, 1)
             end
          end
    end)
    
    
    -- Show the frame
    f:Show()
    
    
    --print("ColorFrame script loaded successfully!")  -- Debug message

    Help by Lua Code
  2. #2
    Delta3's Avatar Member
    Reputation
    2
    Join Date
    Oct 2023
    Posts
    22
    Thanks G/R
    13/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What exactly are you trying to accomplish?

  3. #3
    alic's Avatar Member
    Reputation
    2
    Join Date
    Mar 2025
    Posts
    9
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Link ([Source] Pixel Combat / Rotation Bot) Mazer has provided the code works with Conro addon my question was if someone is able to change the code so that it works with hekili instead of conro

Similar Threads

  1. Need help with lua code
    By rbkz in forum Help & Support
    Replies: 0
    Last Post: 02-25-2018, 12:08 PM
  2. Help plz,Lua code
    By Lololo2016 in forum WoW UI, Macros and Talent Specs
    Replies: 0
    Last Post: 07-21-2016, 07:22 AM
  3. need help on lua code~~
    By sky2009 in forum WoW UI, Macros and Talent Specs
    Replies: 0
    Last Post: 03-01-2016, 11:27 AM
  4. [Request] Help with lua code (Glyph of Fetch)
    By dehahn in forum PE Support forum
    Replies: 2
    Last Post: 11-20-2014, 10:02 AM
  5. [Help] Need someone to test a lua code
    By dude891 in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 04-12-2008, 09:59 PM
All times are GMT -5. The time now is 07:06 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search