The only thing I've been asking is what the line of code would be to add to LUA to cast a spell if mouse4 is pressed. I'm only asking how to tell the addon to cast a spell if I press mouse4, that's all. I never was asking how to make the spell change to a different spell for that key or anything like that.
This is all I'm after, as I have been saying, don't need help with any of the other stuff.
Just need to know how:
An addon can bind a spell to a button, and you can cast that spell in combat by pressing that button
Just need an example snip of that code, that's it.
The current healbot that is working right now in game will cast spells with a mouse click with no bind to any action button, in fact you don't even need the spell to be on any bar at all as long as you have it in your book, I just tried it. Kinda hard to do that if
An addon is not allowed to cast spells via anything that is not a button or keybind while in combat.
If you want to cast Blood strike with mouse4, then bind mouse4 to an actionbutton on your bars and then put Bloodstrike on that button.
I mean I wouldn't question a '4 year guru' like yourself if I wasn't seeing the exact opposite of what you're saying happening right in front of my very eyes...
You don't need a button on your action bar to make an addon cast a spell in combat, cause I just did it a minute ago with healbot....
Exactly what addon are you responsible for if you don't mind my asking? Or 4 years, probably several, which is the most popular?
Project Updated: 2 weeks ago
Files Updated: Thu, Jan 22 2009
I haven't personally used it in about 2 yrs, ... looks like it still works fine though.
The only thing I've been asking is what the line of code would be to add to LUA to cast a spell if mouse4 is pressed. I'm only asking how to tell the addon to cast a spell if I press mouse4, that's all. I never was asking how to make the spell change to a different spell for that key or anything like that. Just need the sniplet so I can try a few things that seem logical from the checks that are currently allowed. The checks that are being done by the addon I use are on myself and the targeted NPC and they seem to work fine and are very accurate. Perhaps we got a little off topic here because I don't need any help with any of that stuff, it already works fine for my needs in the addon I use.
Example: If I click mouse4 during combat the addon will cast Blood Strike - that's pretty much all I'm asking for. I might have added too many details that had nothing to do with what I was actually asking for.
So just need the command to cast a specific spell if mouse4 get's clicked I want to add it in to that snipplet of code you see in my original post.
I'll reply again and be even more specific. The bolded part is correct. You cannot add a line to cast a spell. No addon is allowed to cast a spell when you are in combat, or change what spell a button (button4 in your example) casts (except in response to certain allowed events as I mentioned in my previous post).
In particular, things you cannot respond to, or check to modify a button, includes checking anyone's HP/Mana, status of any and all cooldowns, GCD, anybody's buffs/debuffs, and anything else that would be considered "artificial intelligence".
I'm not talking about a button in game, I'm talking about my "mouse" key. This has nothing to do with any button what so ever. I don't want to modify buttons / macro's, change spells in a button or anything like that. I think we're on different pages. I am only talking about having a key on my mouse able to trigger a cast effect from the addon, with LUA code, hard coded in to the addon. None of the code would need to change during combat, it would all be hardcoded in to the LUA.
As for saying no addon can do all of those things, I know for a fact that is false... Have you ever used Healbot or Decursive?? It pretty much does eveything you just said an addon can't do, while in combat. What's especially cool is the Smart Cast feature "while in combat" from Healbot, it's 100% AI. Healbot can do all of these things in combat from the same left mouse click (or any other key you'd like to use) based on what is needed, Heal (chooses diff spells), Rebuff, Remove Diseases / Curses (in combat if you get afflicted it knows and changes the color of someones name, I'd call that in combat monitoring). It does all of this to other players, even raid wide, while in combat. What I am looking to do is along those same lines. No buttons/macros, at all, not one, natta, zip, zero. This has absolutely nothing to do with changing any buttons.
All of the checks I need done are already being done in this addon, while in combat, I don't need to add a feature to check anything, I was saying it already is set up to do that. I just want to add the ability to bind my mouse4 key to the addon. Unless you're saying an addon can't check to see if a key is pressed during combat or can't cast a detrimental spell (which in the hunter addon linked shows that you can) I still don't understand why you're saying what I'm asking for won't work.
I can only assume you don't know what I'm talking about as you keep referencing buttons. There's no buttons involved in what I'm trying to do. When I said buttons I was referring to the buttons on my mouse / keyboard as in a key bind to a function in the addon, not a macro or something on an action bar.
An addon can suggest spells to cast. But a button cannot be made/changed to cast that suggested spell while in combat.
Nothing would be changing in the addon during combat. The spells would be already determined in each section before combat started and they would cast based on certain circumstances happening, you saying that's not possible? So for example, I need HP, the addon already knows Death Strike is the correct spell I should be using and the DS icon is up. In that same little paragraph of code I can't add a line to also say /cast Death Strike if mouse4 is pressed as it's looping through that code.
I guess I'm not understanding why you're saying it wont work and how's it different from the other addons available that can cast different spells in combat based on variables?
I'm not at all talking about making a button or anything that has to do with a macro. I'm talking about binding a function of an addon to a key on the keyboard. I know macro's can't be edited in combat. Totally not what I'm talking about.
I think my use of the word icon might have thrown you off. I don't mean a button. The icon that appears is just in a widget, it's a graphical aid. Not clickable at all. It just pops up as a picture in the widget to show you what you should be using based on the situation. I want to add functionality to have the addon also cast the same spell that it's suggesting to use.
I'm afraid you cannot have an addon cast suggested spells for you. Addons can only cast spells that are pre-determined before combat starts.
Hmm, that's interesting, I believe healbot can suggest spells to cast if you choose that option. How exactly is that different? You can select to use healbots recommendation when you click people to heal.
The spells are predetermined in a way. The addon will analyze availabe runes, runic power, hitpoints and a few other things then show the icon of which spell it suggests for the situation based on the variables. Why wouldn't you be able to add a line of code in that area of the icon it picks that also says something to the effect of if mouse4 is pressed cast XXXX spell -- it seems logical. I just can't figure out how to correctly add a line of code to tell the addon to do it, I just get LUA errors.
I'd play around with it a bit if I could just get some ideas of what I'm doing wrong. Unless there's something I don't know about that has to do with hostile spells or something.
How about someone just tell me how I'd correctly insert the command with an 'if' statement about mouse4 being pressed to cast a certain spell? What would the parameters be?
Wondering if anyone can provide some assistance. I'm sorta new to LUA and I can't for the life of me seem to get this figured out after searching and experimenting for a few days now.
What I'm trying to do is this:
I have an addon that suggests a rotation for my spells. What I want to do is make it so mouse4 when pressed will cast the suggested spell when it's being suggested. Can anyone give me some idea's for what the code would need to look like, or even PM me and I can discuss further. Willing to donate a few bucks for the help.
if runes > 0 then
if FaceSmasherdb.spec == FaceSmasher.SL["Heart Strike"] and IsSpellInRange(FaceSmasher.SL["Heart Strike"], "target") == 1 then
return FaceSmasher.SL["Heart Strike"]
elseif IsSpellInRange(FaceSmasher.SL["Blood Strike"], "target") == 1 then
return FaceSmasher.SL["Blood Strike"]