Hey, I got a few ideas how you could make more use out of your multiboxing code.
By adding events you could automate alot of functions that you currently have to press a button to make it work.
-- lua code
-- create a frame, lets call it FSMB (FurySwipes MultiBoxing) ^^
FSMB = CreateFrame("Button","FSMB",UIParent)
-- register the events we want to use (this is why we made the frame)
FSMB:RegisterEvent("ADDON_LOADED") -- register event "ADDON_LOADED"
FSMB:RegisterEvent("RAID_ROSTER_UPDATE")
FSMB:RegisterEvent("PARTY_MEMBERS_CHANGED")
FSMB:RegisterEvent("CHAT_MSG_ADDON")
FSMB:RegisterEvent("SPELLCAST_START")
FSMB:RegisterEvent("SPELLCAST_INTERRUPTED")
FSMB:RegisterEvent("SPELLCAST_FAILED")
FSMB:RegisterEvent("SPELLCAST_DELAYED")
FSMB:RegisterEvent("SPELLCAST_STOP")
FSMB:RegisterEvent("PLAYER_REGEN_ENABLED")
FSMB:RegisterEvent("CONFIRM_SUMMON")
FSMB:RegisterEvent("RESURRECT_REQUEST")
FSMB:RegisterEvent("UNIT_INVENTORY_CHANGED")
FSMB:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
FSMB:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
FSMB:RegisterEvent("MERCHANT_UPDATE")
FSMB:RegisterEvent("MERCHANT_FILTER_ITEM_UPDATE")
FSMB:RegisterEvent("MERCHANT_SHOW")
-- create the OnEvent function
function FSMB:OnEvent()
if (event == "ADDON_LOADED") and arg1 == "FSMB" then
-- this event runs once the addon is loaded
-- run all your init functions here
if FSMB_Settings == nil then FSMB_Settings = {} end -- creates a table where you can store all your settings, adding the table to the toc file allows the data to be stored on logout and /reloadui
FSMB:print("Addon loaded successfully!")
FSMB:UnregisterEvent("Addon Loaded") -- unregister the event as we dont need it anymore
elseif (event == "CHAT_MSG_ADDON") then
-- this event fires when an addon sends a message with the command SendAddonMessage()
-- you can use this to send information to anyone using your addon, very efficient.
-- SendAddonMessage("FSMB","a piece of information","RAID") - arg1 = "FSMB" arg2 = "a piece of information" arg4 = the senders unitname
elseif (event == "RAID_ROSTER_UPDATE") then
-- this event fires when your raid members change, when somone leaves/joins/gets moved to another group or connects/disconnects
elseif (event == "PARTY_MEMBERS_CHANGED") then
-- this event fires when your party members change, when somone leaves/joins/connects/disconnects
elseif event == "UNIT_INVENTORY_CHANGED" then
-- this event fires when your inventory changes, you can add functions to keep track of bagspace/inventory items/soulshards etc here
elseif event == "SPELLCAST_START" then
-- this event fires when you start casting
FSMB_Settings["IsCasting"] = true
elseif event == "SPELLCAST_INTERRUPTED" then
-- this event fires when your spells gets interrupted
FSMB_Settings["IsCasting"] = false
elseif event == "SPELLCAST_FAILED" then
-- this event fires when your spell fails
FSMB_Settings["IsCasting"] = false
elseif event == "SPELLCAST_DELAYED" then
-- this event fires when your spell gets delayed
elseif event == "SPELLCAST_STOP" then
-- this event fires when you stop casting
FSMB_Settings["IsCasting"] = false
elseif event == "PLAYER_REGEN_ENABLED" then
-- this event fires when you leave combat, you can put autofollow here for example
elseif event == "CONFIRM_SUMMON" then
-- this event fires when you get a summon request
ConfirmSummon(); -- confirms summon
StaticPopup_Hide("CONFIRM_SUMMON"); -- hides popup frame
elseif event == "RESURRECT_REQUEST" then
-- this event fires when you get a resurrect request
AcceptResurrect() -- accepts resurrection
StaticPopup_Hide("RESURRECT_NO_TIMER"); -- hides popup frame
StaticPopup_Hide("RESURRECT_NO_SICKNESS"); -- hides popup frame
StaticPopup_Hide("RESURRECT"); -- hides popup frame
elseif event == "UNIT_SPELLCAST_CHANNEL_START" then
-- this event fires when you start channeling a spell
FSMB_Settings["IsCasting"] = true
elseif event == "UNIT_SPELLCAST_CHANNEL_STOP" then
-- this event fires when you stop channeling a spell
FSMB_Settings["IsCasting"] = false
elseif event == "MERCHANT_UPDATE" then
-- this event fires when you buy/sell something from a merchant
elseif event == "MERCHANT_SHOW" then
-- this event fires when you visit a merchant, you can add functions such as autobuy here
end
end
-- this will send all the registered events to the OnEvent function
FSMB:SetScript("OnEvent", FSMB.OnEvent) -- event handler
-- print function
function FSMB:print(msg)
if msg then
DEFAULT_CHAT_FRAME:AddMessage("|cffFE2E2EF|cffF78181S|cffF6CECEM|cffFBEFEFB|r: "..msg)
end
end
-- end lua
Notice how all the functions start with the frame we created at the start FSMB:
This will help to keep your code as clean as possible and avoid interference with other addons.
If you look at the events function you will see this FSMB_Settings["IsCasting"], this will be set to true or false depending if you are casting a spell or not, very effecient when making various functions.
I can also show you how you can put your code into your own addon so you won't need supermacro as a dependency.
Let me know if you want more suggestions.
Yeah, MM suggested I simply track my position using a function I didn't know about (GetUnitPosition), then follow if I'm moved. I will get that working :) I imagine it will work WELL for getting my parties back together when bombed by rag.