AutoBuf

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

AutoBuf

#1 Post by Draakje » Sat Sep 27, 2014 8:45 am

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?

Code: Select all

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#2 Post by rock5 » Sat Sep 27, 2014 9:16 am

What happens? Have you tried adding some print messages to check values along the way?
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#3 Post by Draakje » Sat Sep 27, 2014 11:19 am

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#4 Post by rock5 » Sat Sep 27, 2014 11:28 am

It didn't occur to you that it would be easier to find the problem with an error message? :P

The function at line 28 has 1 too many "end"s. I don't know if there are any other problems but that's what I see now.
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#5 Post by Draakje » Sat Sep 27, 2014 11:36 am

Ye i fixed prob was missing an end over there, but now atm addon is working ingame, but not how it should be :D
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

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#6 Post by Draakje » Sat Sep 27, 2014 11:50 am

umm is there a specific function to make it work?

Code: Select all

if OnMessage(Player(Message("Warlock", "Party"))) then
	  target(Player)
	  CastSpellByName("Sublimation Weave Curse")
on and off is working, but when i type Warlock in party chat nothing is going...

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#7 Post by rock5 » Sat Sep 27, 2014 12:52 pm

At first glance there are a couple of functions I don't recognize, SendChatMessage and text, so I can't be sure what it does.

Do you have an xml file in your addon that runes the update function?
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#8 Post by Draakje » Sat Sep 27, 2014 1:27 pm

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#9 Post by rock5 » Sat Sep 27, 2014 1:52 pm

You should monitor party chat, example in your xml onload have.

Code: Select all

this:RegisterEvent("CHAT_MSG_PARTY")
Then also add an onevent section, example

Code: Select all

<OnEvent>  AutoBuffer.OnEvent(event, arg1,arg2,arg3,arg4) </OnEvent>
Then add the function to your lua.

Code: Select all

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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#10 Post by Draakje » Sat Sep 27, 2014 7:11 pm

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?

Lua file

Code: Select all

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
Xml file

Code: Select all

<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
    <Frame name="AutoBuffer_Frame">
        <Scripts>
			<OnLoad>
				this:RegisterEvent("CHAT_MSG_PARTY");
			</OnLoad>

			<OnEvent>
				AutoBuffer.OnEvent(event, arg1,arg2,arg3,arg4)
			</OnEvent>

            <OnUpdate>
                AutoBuffer:OnUpdate(elapsedTime)
            </OnUpdate>
        </Scripts>
    </Frame>
</Ui>

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#11 Post by rock5 » Sun Sep 28, 2014 3:29 am

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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#12 Post by Draakje » Sun Sep 28, 2014 7:44 am

still giving same error

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#13 Post by rock5 » Sun Sep 28, 2014 11:57 am

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.

Code: Select all

/script ReloadUI()
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#14 Post by Draakje » Sun Sep 28, 2014 12:39 pm

yep still getting that message. Maybe u can rewrite the addon? cause i think mine getting totaly messed up or something >.>

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#15 Post by rock5 » Mon Sep 29, 2014 12:20 am

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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#16 Post by Draakje » Mon Sep 29, 2014 7:47 am

yup i've checked, all old ones are deleted no duplicate or backup in addon files.
added file in attachments
Attachments
AutoBuffer.lua
(1.72 KiB) Downloaded 133 times

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#17 Post by rock5 » Mon Sep 29, 2014 8:07 am

Try
Attachments
AutoBuffer.lua
(1.72 KiB) Downloaded 164 times
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#18 Post by Draakje » Mon Sep 29, 2014 8:27 am

yep get error in party chat again
maybe xml file wrong?

Code: Select all

<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
    <Frame name="AutoBuffer_Frame">
        <Scripts>
			<OnLoad>
				this:RegisterEvent("CHAT_MSG_PARTY");
			</OnLoad>

			<OnEvent>
			AutoBuffer.OnEvent(event, arg1,arg2,arg3,arg4)
			</OnEvent>

            <OnUpdate>
                AutoBuffer:OnUpdate(elapsedTime)
            </OnUpdate>
        </Scripts>
    </Frame>
</Ui>

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: AutoBuf

#19 Post by rock5 » Mon Sep 29, 2014 9:10 am

I don't see anything wrong. What error do you get?
  • 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.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Draakje
Posts: 63
Joined: Sat Aug 10, 2013 6:24 am

Re: AutoBuf

#20 Post by Draakje » Mon Sep 29, 2014 10:34 am

call AutoBuffer_Frame's OnEvent, line: [string "?"]:34: attempt to call field 'VN' (a nil value)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 25 guests