Originally Posted by
testcharsdf
I have no Lua skills whatsoever.
MACRO 1: What I want is to combine the following macros into one SuperMacro!
Macro 1:
/run pAy={[16]="Instant Poison VI",[17]="Deadly Poison VI"};UA=UseAction;mE,_,_,oE=GetWeaponEnchantInfo();if mE==nil then pK=16;UA(XX);elseif oE==nil then pK=17;UA(XX);end;
Macro 2: (slot XX)
/run for i=0,4 do for j=1,GetContainerNumSlots(i) do cSI=GetContainerItemLink(i,j);if cSI then if(strfind(cSI,pAy[pK]))then UseContainerItem(i,j);PickupInventoryItem(pK);do return;end;end;end;end;end;
What I ended up with is:
/run PSN={[16]="Instant Poison",[17]="Instant Poison"}; mE,_,_,oE=GetWeaponEnchantInfo(); if mE==nil then n=16; elseif oE==nil then n=17; end; while n>=16 do for i=0,4 do for j=1,32,1 do cSI=GetContainerItemLink(i,j); if cSI and (strfind(cSI,PSN[n])) then UseContainerItem(i,j); PickupInventoryItem(n); do return end; end; end; end; end; end; end;
but I honestly have no idea how to debug properly. The error message I get is: "<string>:"PSN={[16]="Instant Poison",[17]="Instant Poison"}; mE,_,_,oE=Ge...":1: `end' expected near `<eof>'" but since I don't know Lua I can't really tell if I put too many ends, not enough ends or whether something else is broken.
Help me repair it or come up with a better, working solution please! thx
Paste this code into notepad and save it as addonname.Lua you can change addon name to whatever.
make a macro in game that has just the command /dp or /dpspoison put it on your bar. If you click it, it will poison your main hand. if you hold Alt it will poison your offhand. If you hold Ctrl it will use Deadly poison instead of instant poison. Ctrl+alt = Deadly poison on offhand. It will also announce how much poison you have remaining.
Code:
SLASH_DDPOISON1, SLASH_DDPOISON2 = "/dpspoison", "/dp"
function SlashCmdList.DDPOISON()
if not IsControlKeyDown() then
local instant=0
for x=0,4,1 do
for y=1,GetContainerNumSlots(x),1 do z= GetContainerItemLink(x,y)
if z and string.find(z,"Instant Poison") then
local _, itemCount = GetContainerItemInfo(x,y);
instant= instant + itemCount;
UseContainerItem(x,y)
end
end
end
if IsAltKeyDown() then
PickupInventoryItem(17) ReplaceEnchant() ClearCursor()
if instant==0 then DEFAULT_CHAT_FRAME:AddMessage("You have no Instant Poison. Purchase more!")
else instant= instant - 1
DEFAULT_CHAT_FRAME:AddMessage("Using Instant Poison on Off-hand. "..instant.." remaining.")end
else PickupInventoryItem(16) ReplaceEnchant() ClearCursor()
if instant==0 then DEFAULT_CHAT_FRAME:AddMessage("You have no Instant Poison. Purchase more!")
else instant= instant - 1
DEFAULT_CHAT_FRAME:AddMessage("Using Instant Poison on Main-hand. "..instant.." remaining.")end
end
end
if IsControlKeyDown() then
local deadly=0
for x=0,4,1 do
for y=1,16,1 do z= GetContainerItemLink(x,y)
if z and string.find(z,"Deadly Poison") then
local _, itemCount = GetContainerItemInfo(x,y);
deadly = deadly + itemCount
UseContainerItem(x,y)
end
end
end
if IsAltKeyDown() then
PickupInventoryItem(16) ReplaceEnchant() ClearCursor()
if deadly==0 then DEFAULT_CHAT_FRAME:AddMessage("You have no Deadly Poison. Purchase more!") end
if not deadly==0 then
DEFAULT_CHAT_FRAME:AddMessage("Using Deadly Poison on Main-hand. "..deadly.." remaining.")end
else PickupInventoryItem(17) ReplaceEnchant() ClearCursor()
if deadly==0 then DEFAULT_CHAT_FRAME:AddMessage("You have no Deadly Poison. Purchase more!") end
if not deadly==0 then
DEFAULT_CHAT_FRAME:AddMessage("Using Deadly Poison on Off-hand. "..deadly.." remaining.")end
end
end
end
after you make your LUA file you will need to make a second file in notepad
put this code into your 2nd file and name it addonname.toc again you can name addonname anything you like.
Code:
## Interface: 120000
## Title: Addonname
## Notes: "This is the text that will show up in-game character select screen if you open the Addon window
## Author: Oderus
addonname.lua
Make sure you change addonname.lua to the same name as whatever your named your lua file.
After that put it into a folder with your addon name and put it in your addons folder.
Sorry i know its not what you necessarily asked for but im just sharing my own personal script that i use.
I also have this code built into my rotation to spam my chat window if my poisons are about to fade or are missing; You can add conditionals to make it only spam if youre out of combat or 100+ energy so it doesnt spam so bad.
Code:
hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo();
if not hasMainHandEnchant then DEFAULT_CHAT_FRAME:AddMessage("Missing poison in Main hand") end
if not hasOffHandEnchant then DEFAULT_CHAT_FRAME:AddMessage("Missing poison in Off hand") end
if hasMainHandEnchant and (mainHandExpiration/1000)<=180 then DEFAULT_CHAT_FRAME:AddMessage("Poison expiring in Main hand..") end
if hasOffHandEnchant and (offHandExpiration/1000)<=180 then DEFAULT_CHAT_FRAME:AddMessage("Poison expiring in Off hand..") end