You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


/!\ We have moved to a new board. Come join us. This board is now in "archive" (read-only mode). /!\

1

Wednesday, May 20th 2015, 9:25pm

CastSpellByName Broke

/run CastSpellByName("Insert Name");

No longer works outside of macros. This broke an addon I had coded, and I don't know when the change was made, is there a way to combat this issue? Because I cant fit a couple hundred lines of code, into a macro. Is there anyways to simply have an addon cast a spell? I honestly couldn't care how convoluted the solution is. This sort of broke my key addon, and nothing works combat wise now.

The only other way this could work, is if someone figure out how to do some major event handling inside a macro. Is there a way to trigger a macro when an event is called (such as someone saying something in guild), this would also combat my issue (at least a more complicated workaround.) I have all the code I need. Just the cast spell by name wont work...

- A frustrated coder.

2

Wednesday, May 20th 2015, 9:40pm

CastSpellByName only works when its used in a handler for a user input event (e.g. mouse clicks, key presses, stuff like that). It has been this way since at least chapter 3, maybe even earlier o.O

If you would post your little addon (or send it to me per PM) I could take a look to see what might be the reason for it not working.
Mithrandir - Warden/Warrior/Scout/Druid 95/95/95/87 (Dochas) - yes, I'm german :P
Creator of RaidHeal (Curse)

This post has been edited 1 times, last edit by "hoffmale" (May 20th 2015, 10:43pm)


3

Wednesday, May 20th 2015, 10:44pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 function KRB()
     if (Very large snipped condition) then
          if(KCheckFriendlyBuffs("BUFF_NAME")) then
               --Nothing happens
          else
               CastSpellByName("BUFF_NAME")
          end
          WaitTimer.Wait(1, KRB,"KRBTimer")
     else
          if (UnitIsUnit("focus1", "target")) then
               --Nothing happens
          else
               KMoveTo("0")
          end
     end
end


This was my issue, I need event handling which then triggers some error checking and other stuff, ultimately landing us in KMoveTo, KMoveTo, may or may not call KRB (The function you are looking at.) KRB then loops through (calling tradition WaitTimer via LibStub). Now Worse case I can call the KMoveTo, and it works, except for the second time the buff would apply. I can get it to do /castSpellbyname once, but once I encounter the wait timer, I simply can't get it to happen again. If you need any more code i'd be happy to supply, but I do anonymize the code (purpose doesn't change just names) until it is a finished product.

This post has been edited 1 times, last edit by "ftwoplay" (May 20th 2015, 10:52pm) with the following reason: Because


4

Wednesday, May 20th 2015, 10:57pm

WaitTimer is implemented as a handler for OnUpdate, during which CastSpellByName won't work (since OnUpdate isn't triggered by user input). If you have to wait a bit the only way is to use /wait in the macro.

Addon:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function KRB()
     if (Very large snipped condition) then
          if(KCheckFriendlyBuffs("BUFF_NAME")) then
               --Nothing happens
          else
               CastSpellByName("BUFF_NAME")
          end
          --WaitTimer.Wait(1, KRB,"KRBTimer")
          return false
     else
          if (UnitIsUnit("focus1", "target")) then
               --Nothing happens
          else
               KMoveTo("0")
          end
     end
     return true
end


Macro:

Source code

1
2
3
4
5
6
/run c=KRB()
/wait 1
/run c=c or KRB()
/wait 1
/run c=c or KRB()
...
Mithrandir - Warden/Warrior/Scout/Druid 95/95/95/87 (Dochas) - yes, I'm german :P
Creator of RaidHeal (Curse)

5

Wednesday, May 20th 2015, 10:59pm

I'll send you most of the addon, and explain what i'm doing. Hopefully you can help me think of a better way around this. Do you have vent/curse voice? So we can talk?

6

Wednesday, May 20th 2015, 11:04pm

I have teamspeak or Skype ^^ If my last edit doesn't solve this for you xD
Mithrandir - Warden/Warrior/Scout/Druid 95/95/95/87 (Dochas) - yes, I'm german :P
Creator of RaidHeal (Curse)

7

Wednesday, May 20th 2015, 11:10pm

PM me with a teamspeak server. :)