Add your class specific function below all that code (in the MyFunctions.lua file). If there isn't a function already posted for your class combo, start with one that someone else posted and modify it to suit your class, or ask for one and we'll get you started.
)' functions then yes there's nothing wrong with that.
Quoted from "dashort;239832"
The problem I'm having, however, is that mine doesn't seem to recognize when I'm in combat, and if my buff fails while I'm fighting, it stops to rebuff.
|
|
Source code |
1 |
local combat = GetPlayerCombatState() |
Quoted from "dashort;239832"
Also, There is a problem when I'm using that macro to heal, it just keeps casting regenerate and not urgent heal. I'm R/P btw and thanks again!
|
|
Source code |
1 |
local pbuffs = BuffList("player")
|

|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
g_skill = {}
function Msg(outstr,a1,a2,a3)
DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end
function ReadSkills()
g_skill = {}
local skillname,slot
Msg("- Reading Class Skills")
for page = 2,4 do
slot = 1
skillname = GetSkillDetail(page,slot)
repeat
local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
if skillusable then
g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
end
slot = slot + 1
skillname = GetSkillDetail(page,slot)
until skillname == nil
end
end
ReadSkills() -- Read skills into g_skill table at login
function PctH(tgt)
return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end
function ChkBuff(tgt,buffname)
local cnt = 1
local buffcmd = UnitBuff
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
if buff == buffname then
return true
end
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return false
end
function BuffList(tgt)
local cnt = 1
local buffcmd = UnitBuff
local buffstr = "/"
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
buffstr = buffstr..buff.."/"
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return buffstr
end
function CD(skillname)
local firstskill = GetSkillDetail(2,1)
if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
ReadSkills()
end
if g_skill[skillname] ~= nil then
local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
return cd==0
else
Msg("Skill not available: "..skillname)
return false
end
end
function MyCombat(Skill,arg1)
local spell_name = UnitCastingTime("player")
local talktome = false
if (arg1 == "v1") or (arg1 == "v2") then
talktome = true
end
if spell_name ~= nil then
if (arg1 == "v2") then Msg("- ['..spell_name..']",0,1,1) end
return false
end
for x,tbl in ipairs(Skill) do
if CD(Skill[x].name) and Skill[x].use then
if talktome then Msg("- "..Skill[x].name) end
CastSpellByName(Skill[x].name)
return true
end
end
if (arg1 == "v2") then Msg("- IDLE") end
return false
end
function KnightGeneric(arg1,arg2)
local Skill = {}
local i = 0
local tgt = "player"
local friendly = UnitCanAttack("player","target")
local shield = (GetEquipSlotInfo(17) ~= nil)
local health = PctH("player")
local mana = UnitMana("player")/UnitMaxMana("player)
local tgtcast,tgttime,tgtelapsed = UnitCastingTime("target")
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")
i=i+1; Skill[i] = { ['name'] = "Holy Shield", ['use'] = (health <= .25) }
i=i+1; Skill[i] = { ['name'] = "Resolution", ['use'] = (health <= .33) }
i=i+1; Skill[i] = { ['name'] = "Shield of Atonement", ['use'] = ((not friendly) and (health <= .40) and shield) }
i=i+1; Skill[i] = { ['name'] = "Shield of Valor", ['use'] = ((not friendly) and (health <= .50) and shield) }
i=i+1; Skill[i] = { ['name'] = "Shield of Discipline", ['use'] = ((not friendly) and (tgttime >1) and shield) }
i=i+1; Skill[i] = { ['name'] = "Enhanced Armor", ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
i=i+1; Skill[i] = { ['name'] = "Holy Seal", ['use'] = (not string.find(pbuffs,"Holy Seal")) }
i=i+1; Skill[i] = { ['name'] = "Threaten", ['use'] = (string.find(tbuffs,"Holy Seals %(3%)") and (not string.find(pbuffs,"Threaten")) and (arg2 == "threaten")) }
i=i+1; Skill[i] = { ['name'] = "Mana Return", ['use'] = (string.find(tbuffs,"Holy Seals %(3%)")) }
i=i+1; Skill[i] = { ['name'] = "Whirlwind Shield", ['use'] = ((not friendly) and shield) }
i=i+1; Skill[i] = { ['name'] = "Holy Strike", ['use'] = ((not friendly) and (mana >= .5)) }
i=i+1; Skill[i] = { ['name'] = "Joint Blow", ['use'] = ((not friendly) and (mana < .5)) }
MyCombat(Skill,arg1)
end
|
Quoted from "foreshard;239976"
Alright. I have all the code set up now. I followed the "nutshell" instructions, made sure the path to the MyFunctions folder is correct, made the two text documents (named: MyFunctions.toc and MyFunctions.lua) put the MyFunctions.lua inside the .toc and saved it. Inserted all the first post page code + codes following the outlines posted here. ok seems everything is as it should.
get into the game, try to do the /run ReadSkills() command, but i dont get a response that says it read the skills, nor do i get a error msg in the chat box. no confirmation and no errors, sooo what did i do wrong then??
|
|
Source code |
1 |
/run Msg("hello")
|
|
|
Source code |
1 |
/run ReadSkills() |
Quoted from "Provoke;240154"
First up bear with me, as I'm just not very good with code.
This is my MyFunctions.lua code:
This doesn't work for me. As in, when I run "/run KnightGeneric("v1")" in a macro, nothing happens.
![]()
Source code
1 <snip>
I ran "/run ReadSkills()" but no feedback.
So I deleted the knight specific code leaving only the original code on page #1 of block #1 (the main code without the knight stuff), restarted the game and then ran "/run ReadSkills()" which did give me feedback...
Where am I going wrong?
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function KnightGeneric(arg1,arg2)
local Skill = {}
local i = 0
local friendly = (not UnitCanAttack("player","target"))
local shield = (GetEquipSlotInfo(17) ~= nil)
local combat = GetPlayerCombatState()
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")
i=i+1; Skill[i] = { ['name'] = "Whirlwind Shield", ['use'] = ((not friendly) and shield) }
i=i+1; Skill[i] = { ['name'] = "Enhanced Armor", ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
i=i+1; Skill[i] = { ['name'] = "Holy Seal", ['use'] = (not string.find(pbuffs,"Holy Seal")) }
i=i+1; Skill[i] = { ['name'] = "Threaten", ['use'] = (string.find(tbuffs,"Holy Seals 3") and (not string.find(pbuffs,"Threaten")) and (arg2 == "threaten")) }
i=i+1; Skill[i] = { ['name'] = "Mana Return", ['use'] = (string.find(tbuffs,"Holy Seals 3")) }
i=i+1; Skill[i] = { ['name'] = "Punishment", ['use'] = ((not friendly) and string.find(tbuffs,"Light Seal III")) }
i=i+1; Skill[i] = { ['name'] = "Holy Strike", ['use'] = (not friendly) }
MyCombat(Skill,arg1)
end
|
I use Notepad and have the same problem if I'm copying into the game macro editor. I've just gotten into the habit of hitting backspace at the end of each line until I erase a legit character (replacing it of course).
Quoted
Also I what text editor are you guys using? I noticed that when copy/pasting from notepad it seems to add invisible characters which further bug the code.
Quoted from "Sixpax;240164"
That sounds like I have an error in my KnightGeneric() code somewhere. I didn't test that so please forgive me for that. Tigs posted his (working) K/W code on post #16 so you might try that, or start with something simple and go from there. Try this one:
[code]...
Try that one and let me know if executes those skills.
I use Notepad and have the same problem if I'm copying into the game macro editor. I've just gotten into the habit of hitting backspace at the end of each line until I erase a legit character (replacing it of course).
Your doing me a favour.
Quoted from "Provoke;240171"
No reason to excuse yourselfYour doing me a favour.
So I replaced the knight specific code and it executed.
|
|
Source code |
1 |
/run KnightGeneric("","threaten")
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
function ChkBuffTime(tgt,buffname)
local cnt = 1
local buffcmd = UnitBuff
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
if buff == buffname then
return GetPlayerBuffLeftTime(cnt-1)
end
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return false
end
function MyBuffs()
if not ChkBuff("target","Enhanced Armor") then
Msg("Casting Enhanced Armor")
CastSpellByName("Enhanced Armor")
else
if (ChkBuffTime("target","Enhanced Armor") > 30) then
Msg("Armor is already up and greater than 30s")
else
if (ChkBuffTime("target","Enhanced Armor") < 30) then
Msg("Casting Enhanced Armor bc buff is less than 30s")
CastSpellByName("Enhanced Armor")
end
end
end
end
|
|
|
Source code |
1 2 3 4 5 |
/run PickupEquipmentItem(16) PickupEquipmentItem(15) /wait .1 /cast Shadowstab /wait .1 /run PickupEquipmentItem(16) PickupEquipmentItem(15) |
Quoted from "HuBu;241606"
I kind changed Sixpax's code for ChkBuff() to return the count the buff you looking for then use that to get the remaining time on the buff.
EDIT 1 - Doesn't work? seems that GetPlayerBuffLeftTime() has to be GetPlayerBuffLeftTime(cnt-1)
EDIT 2 - Got it to work. Code is updated.
![]()
Source code
1 <snip>
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
function MyBuffs()
local mybuffs = { "Enhanced Armor", "Holy Seal" }
for i,buffname in pairs(mybuffs) do
if (ChkBuffTime("player",buffname) < 30) then
Msg("Casting "..buffname)
CastSpellByName(buffname)
return
end
end
end
|
Quoted from "LucasUpright;236849"
Preliminary function for RogueKnight:
How does that look?
![]()
Source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24function RogueKnight(arg1,arg2) local Skill = {} local i = 0 local energy = UnitMana("player") local mana = UnitSkill("player") local friendly = (not UnitCanAttack("player","target")) local combat = GetPlayerCombatState() local pbuffs = BuffList("player") local tbuffs = BuffList("target") i=i+1; Skill[i] = { ['name'] = "Enhanced Armor", ['use'] = (not string.find(pbuffs,"Enhanced Armor")) } i=i+1; Skill[i] = { ['name'] = "Lions Protection", ['use'] = (not string.find(pbuffs,"Lions Protection")) } i=i+1; Skill[i] = { ['name'] = "Premeditation", ['use'] = ((not string.find(pbuffs,"Premeditation")) and (not combat)) } i=i+1; Skill[i] = { ['name'] = "Sneak Attack", ['use'] = ((not friendly) and (energy >=30) and (arg2=="behind") and (not combat)) } i=i+1; Skill[i] = { ['name'] = "Wound Attack", ['use'] = ((not friendly) and (energy >=35) and (string.find(tbuffs,"Bleed") and (string.find(tbuffs,"Grievous Wound")))) } i=i+1; Skill[i] = { ['name'] = "Low Blow", ['use'] = ((not friendly) and (energy >=35) and (string.find(tbuffs,"Bleed"))) } i=i+1; Skill[i] = { ['name'] = "Blind Spot", ['use'] = ((not friendly) and (energy >=25) and (arg2=="behind")) } i=i+1; Skill[i] = { ['name'] = "Shadowstab", ['use'] = ((not friendly) and (energy >=35)) } i=i+1; Skill[i] = { ['name'] = "Disarmament", ['use'] = (not friendly) } MyCombat(Skill,arg1) end
Quoted from "Sixpax;242059"
Here's a little tip for you that will simplify your code a bit. In your ChkBuffTime() function, have it "return 0" at the end instead of "return false". That way for buffs that you don't have on you'll still get a number. So you'll only need to do the ChkBuffTime() check. Also, if you're making a buffing function, you can define all the buffs you want to cast and have it cycle through all of them until it finds one you're missing. So you won't need to have separate if/then statements for each one. For instance: