Hey there, Im trying to make an addon that autobuffs ppl. Details: Person in party/raid types like "warlock" and the alt targets the person and casts the buff on the player.
I think my function is not correct, could someone have a look onto it?
local disabled = false -- Starting value
SLASH_AutoBuffer1 = "/AutoBuffer"
SLASH_AutoBuffer2 = "/AB" -- Add as many variations as you like just increment the number
SlashCmdList["AutoBuffer"] = function(editBox, msg)
if msg then
msg = string.lower(msg)
if msg == "on" then -- on
disabled = false
elseif msg == "off" then -- off
disabled = true
else
disabled = not disabled -- Toggles addon if 'on' or 'off' is not used.
end
if disabled then
SendSystemChat("AutoBuffer is disabled")
SendChatMessage("|H|h|cffFF0000AutoBuffer has been deactivated|h", "party")
else
SendSystemChat("AutoBuffer is enabled")
SendChatMessage("|H|h|cff16DC07AutoBuffer has been activated|h", "party")
end
end
end
local AutoBuffer = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.AutoBuffer = AutoBuffer -- expose it to the global scope
function AutoBuffer.VN()
for xx = 1 , 36 do
if OnMessage(Player(SendChatMessage("Warlock", "Party"))) then
CastSpellByName("Sublimation Weave Curse")
end
end
end;
-- Searches the target for a specified text.
-- Use "player", "target", "party3", "raid1" etc. for tgt parameter.
function OnMessage(Player,SendChatMessage)
local counter=1
local SendChatMessage="none"
while Player ~= nil do
SendChatMessage=text(player,msg)
if message ~= nil then
if string.find(string.lower(target),string.lower(message)) then
return true
else
counter=counter+1
end
end
end
return false
end
local time_remaining = 1 -- in seconds
function AutoBuffer:OnUpdate(elapsed)
if disabled == true then
return
end
-- elapsed is the amount of time in seconds since the last frame tick
time_remaining = time_remaining - elapsed
if time_remaining > 0 then
-- cut out early, we're not ready yet
return
end
time_remaining = 1 -- reset to 2 seconds
self.VN()
end
not sure what u meaning with addind print msg in :s
program saying this: lua: AutoBuffer.lua:69: 'end' expected (to close 'function' at line 28) near '<eof>'
quitting debugger
Ye i fixed prob was missing an end over there, but now atm addon is working ingame, but not how it should be
My char itself is trying to spam the word warlock all over ^^. While the word must be an activation for it to cast a skill xd
yes the update works also inside my xml file
its just I don't know a function to let the char use a skill when a player types in party chat example "warlock"
also let it target player aswell if possible
function AutoBuffer.OnEvent(event, arg1, arg2, arg3, arg4)
if event == "CHAT_MSG_PARTY" then
if arg1 == "warlock" then
-- Do stuff. Maybe ..
self.VN()
end
end
end
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
I'm getting error in my party chat as soon i typed "warlock": call AutoBuffer_Frame's OnEvent, line: [string "?"]:34: attempt to index global 'self' (a nil value)
Something still missing in lua file?
local disabled = false -- Starting value
SLASH_AutoBuffer1 = "/AutoBuffer"
SLASH_AutoBuffer2 = "/AB" -- Add as many variations as you like just increment the number
SlashCmdList["AutoBuffer"] = function(editBox, msg)
if msg then
msg = string.lower(msg)
if msg == "on" then -- on
disabled = false
elseif msg == "off" then -- off
disabled = true
else
disabled = not disabled -- Toggles addon if 'on' or 'off' is not used.
end
if disabled then
SendSystemChat("AutoBuffer is disabled")
SendChatMessage("|H|h|cffFF0000AutoBuffer has been deactivated|h", "party")
else
SendSystemChat("AutoBuffer is enabled")
SendChatMessage("|H|h|cff16DC07AutoBuffer has been activated|h", "party")
end
end
end
local AutoBuffer = {} -- the AddOn namespace, all your functions should be placed inside here instead of as globals.
_G.AutoBuffer = AutoBuffer -- expose it to the global scope
function AutoBuffer.OnEvent(event, arg1, arg2, arg3, arg4)
if event == "CHAT_MSG_PARTY" then
if arg1 == "warlock" then
TargetUnit("player", "event")
CastSpellByName("Sublimation Weave Curse")
self.VN()
end
end
end
local time_remaining = 1 -- in seconds
function AutoBuffer:OnUpdate(elapsed)
if disabled == true then
return
end
-- elapsed is the amount of time in seconds since the last frame tick
time_remaining = time_remaining - elapsed
if time_remaining > 0 then
-- cut out early, we're not ready yet
return
end
time_remaining = 1 -- reset to 2 seconds
AutoBuffer.VN()
end
I'm guessing line 34 is "self.VN()". Try changing it to "self.VN()". That should have been obvious especially as you have self.VN() further in the file.
The reason it didn't work the way I wrote it is because the function was written with a dot (.) instead of a colon (:). So in this case self wouldn't work.
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
You replaced "self" with "AutoBuffer" and you still get "attempt to index global 'self' (a nil value)"? Maybe you forgot to save it before trying again. Or maybe you forgot to restart the game to make the changes take affect. Instead of restarting the game you can issue the following command from chat line.
Another possibility is you made a backup copy of the addon in the addons folder and it's still being loaded and overwriting the updated version. Make sure you only have 1 copy of the addon in the addons folder.
Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.