• Dear Guest,

    You're browsing our forum as a Guest meaning you can only see a portion of the forum in read-only mode.
    To view all forum nodes and be able to create threads/posts please register or log-in with your existing account.

    TwinStar team

Help writing a macro

RP80

New Member
Joined
Aug 22, 2014
Just started to play on Kronos. Was wondering if anyone could help me out with constructing a macro? Not sure if it is possible to make it the way I want though.

I am using Luna Unit Frames, https://github.com/Aviana/LunaUnitFrames/wiki

"-Mouseover casting system: Use /lunamo or /lunamouseover followed by your spell of choice to make the macro behave like a normal spell button on your bar but when you are over a frame it casts on that target."

"-Mousover scripting support (for the advanced users)
Example:

/lunamo SmartHeal:Cast('Flash Heal')
For the time the code is executed you have the correct target so whatever code you are executing just needs to interact with the unit "target"."


Wanted to combine this mouseover feature with the following macro:


/run m=0 for i=1,40 do if(strfind(tostring(UnitBuff("target",i)),"Spell_Nature_Rejuvenation"))then m=1 end end if m==0 then CastSpellByName("Rejuvenation(Rank 4)") end

( makes you unable to cast and overwrite another rejuvenation, good when there are multiple druids)



Is there anyway to do this?



Would be very grateful for any help.
 
Last edited:
You seem to have the correct script already. Just replace CastSpellByName("Rejuvenation(Rank 4)") with the lua function SmartHeal:Cast('Flash Heal'). This function might be called differently in LUNA.

Regarding your mouseover. There is a unittype called "mouseover". That only works for actual characters though that you hover over, not the frames. In the LUF code you might find a global variable that refers to that unit and gives you the unit by the name you hover over. By that you can implement this into your macro.

Another solution is to manipulate the script itself in the LUF code to do what you want on every or specific casts.

cheers!
 
Thanks for the quick reply, appreciate it.
I am totally lost though for how to make the macro. The rejuvenation macro I didn't write myself, way to advanced for me so in over my head. Don't know what to do. Tried this:

/run m=0 for i=1,40 do if(strfind(tostring(UnitBuff("target",i)),"Spell_N ature_Rejuvenation"))then m=1 end end if m==0 then SmartHeal:Cast('Rejuvenation')')

Didn't work. Tried to browse the Luna page to see if I could find some list of commands there but no luck.

Error message I got looked like this by the way:
[string "m=0 for i=1,40 do if (strfind(tostring(UnitBuff("target" ,i)), "Sp... "]: 1 :unitfinished string near `<eof>'


Any ideas?
Would be so fantastic to get this macro working. Have everything else setup the way I want it.
 
Replace line 34 to 85 in LunaUnitFrames.lua in your addon folder with:

Code:
local t = {}
local func = function(c) tinsert(t,c) end

function unitHasBuff(unit, buff)
    for i=1,40 do 
        if(strfind(tostring(UnitBuff(unit,i)),buff))then 
            return false
        end 
    end
    return true
end

SLASH_LUFMO1, SLASH_LUFMO2 = "/lunamo", "/lunamouseover"
function SlashCmdList.LUFMO(msg, editbox)
   t = {}
    string.gsub(arg2, "(.-),", func)
    msg, text = t[1], t[2]
    local func = loadstring(msg)
    if LunaUF.db.profile.mouseover and UnitExists("mouseover") then
        if UnitIsUnit("target", "mouseover") then
            if unitHasBuff("target", text) then
            if func then
                func()
            else
                CastSpellByName(msg)
            end
            end
            return
        else
            if unitHasBuff("mouseover", text) then
            TargetUnit("mouseover")
            if func then
                func()
            else
                CastSpellByName(msg)
            end
            TargetLastTarget()
            end
            return
        end
    end
    if GetMouseFocus().unit then
        if UnitIsUnit("target", GetMouseFocus().unit) then
            if unitHasBuff("target", text) then
            if func then
                func()
            else
                CastSpellByName(msg)
            end
            end
        else
            LunaUF.Units.pauseUpdates = true
            if unitHasBuff(GetMouseFocus().unit, text) then
            TargetUnit(GetMouseFocus().unit)
            if func then
                func()
            else
                CastSpellByName(msg)
            end
            TargetLastTarget()
            end
            LunaUF.Units.pauseUpdates = nil
        end
    else 
        if unitHasBuff("target", text) then
        if func then
            func()
        else
            CastSpellByName(msg)
        end
        end
    end
end

Your macro has to look like this:
/lunamo SmartHeal:Cast("Rejuvenation(Rank 4)"),Spell_Nature_Rejuvenation,

If you have macros that dont require the check it must look like this
/lunamo SmartHeal:Cast("Rejuvenation(Rank 4)"),NONE,

I didnt test it, just wrote it real fast, but maybe worrth a try for you.

Make a copy of the lua before you edit it. If it doesnt work replace it with it.

cheers!
 
Big thanks! Really great of you to take the time to help out. Fantastic. Hopefully it will work.

Am away from home so can't test it until Wednesday. I'll post again once I try it out.

Thanks again.
 
UnitBuff doesnt work like that in vanilla, argument 1 gives you the path to the icon instead...
 
The no-overwrite macro I use goes like this (Supermacro required, is mouseover):

/script s="Rejuvenation"; if (TLTP == nil) then CreateFrame("GameTooltip","TLTP",nil,"GameTooltipTemplate"); TLTP:SetOwner(WorldFrame,"ANCHOR_NONE"); end function VGRT_CastSpellWithCheck(tar) c=0; i=1; while(UnitBuff(tar,i) ~= nil) do TLTP:SetUnitBuff(tar,i); if (strfind(TLTPTextLeft1:GetText(),s) ~= nil) then c=1; break; end i=i+1; end if (c == 0) then CastSpellByName(s); end end if GetMouseFocus().unit then if UnitIsUnit("target", GetMouseFocus().unit) then VGRT_CastSpellWithCheck("target") else TargetUnit(GetMouseFocus().unit); VGRT_CastSpellWithCheck("target"); TargetLastTarget(); end else if (UnitName("target")==nil) then VGRT_CastSpellWithCheck("player"); else VGRT_CastSpellWithCheck("target"); end end

Credits to Ermean for making it.
 
Top Bottom