I should probably have been more specific. An addon can bind a spell to a button, and you can cast that spell in combat by pressing that button. What an addon cannot do is rebind it during combat, which is what your original first post wants.
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
This simply cannot be done. The addon can suggest spells for you while in combat, but it cannot rebind mouse4 to that spell for you while in combat. The addon can bind spellX to mouse4 for you before combat, but all you can do is then cast that spell (or macro) and only that spell (or macro) with that mouse button until you next exit combat, or an allowed Blizzard approved event allows you to change what it is binded to.
As for what addons I am responsible for, you can read my signature.
Drop the drama bullshit or I'm locking this thread.
There is no drama. I am patiently explaining why it isn't possible anymore, he merely refuses to accept it.
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 don't know how many times I need to tell you: There is no such line of code that can achieve this. 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'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.
No we are not on different pages. A mouse button is treated exactly like a keyboard button. "Mouse4" is no different from say "2" or "Q" on your keyboard. They are buttons.
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.
A key on your mouse can trigger a cast effect. But the spell that is casted CANNOT be determined in real time by an addon.
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.
Decursive and Healbot no longer works in the way you described since patch 2.0 about 2.5 years ago. That is, Blizzard made changes so that addons cannot one-button spam decurse or heal anymore since November 2006. The current Decursive now just sets up 25 small pretty buttons on your screen, and you click them *manually* to decurse a specific person. The decurse spell is predefined and does not change during combat. Each of those small pretty buttons is set up to decurse a specific person. Want to spam hit the button "G" to decurse the whole raid? Sorry, that's only in 2006, we're in 2009 now.
And Healbot? It hasn't been working since 2006.
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.
Please do not assume we know nothing about addon programming, we have been doing it for 4 years. When we say it is impossible, it really is impossible.
Keybinding a keyboard button (or mouse button), to a spell, or to a macro, or to a function, all means the same thing. It is still keybinding a physical input hardware button to an action in game, it doesn't matter what the action is, it can be a function, a spell, a macro, etc. It can't be done in combat. Since November 2006.
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'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".
Still not possible. Addons cannot check for those circumstances and change the button's spell for you or rebind the button for you.
The events are mutually exclusive. A button's spell/rebinding in combat can only occur to things Blizzard allows you to respond to - such as stance change, stealthing, entering vehicle, pet summon, etc. You can't check for your HP and respond to it by rebinding the spell or rebinding the button.
Trust me on this.
Bottom line: An addon can suggest what to cast - but it cannot cast it for you, nor rebind it to some convenient button for you so that you only need to spam one button. Blizzard made sure its not possible.