Thread Tools Display Modes
01-03-12, 02:47 AM   #1
Jonisaurus
An Aku'mai Servant
 
Jonisaurus's Avatar
Join Date: Aug 2011
Posts: 35
Sending raw slash command.

Code:
local frame = CreateFrame("Frame")

frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
frame:RegisterEvent("UNIT_SPELLCAST_DELAYED")
frame:RegisterEvent("UNIT_SPELLCAST_FAILED")
frame:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET")
frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
frame:RegisterEvent("UNIT_SPELLCAST_SENT")
frame:RegisterEvent("UNIT_SPELLCAST_START")
frame:RegisterEvent("UNIT_SPELLCAST_STOP")
frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")

local function RunSlashCmd(cmd)
		local slash, rest = cmd:match("^(%S+)%s*(.-)$")
		ChatFrame_ImportAllListsToHash()
		local handler = hash_SlashCmdList[slash:upper()]
		if handler then
			handler(rest)
		end
end

local function PageMe(self, event, ...)
	local class, classFileName = UnitClass("player")
	if unitId == "player" and classFileName == "PRIEST" then
		RunSlashCmd("/changeactionbar 1")
	end
end

frame:SetScript("OnEvent", RunSlashCmd)


I'm trying to run a slash command (/changeactionbar 1) when casting a spell.
It not be working.
I took the code from here http://us.battle.net/wow/en/forum/topic/3657445305.


Please halp.:<

Last edited by Jonisaurus : 01-03-12 at 02:53 AM.
  Reply With Quote
01-03-12, 03:14 AM   #2
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
I can't tell you if this is the most direct reason why it's not working (it may be due to a bug in RunSlashCmd or something--I didn't run that code nor do I really understand how it's supposed to work), but according to WoWPedia, ChangeActionBarPage() is protected when in combat. It stands to reason therefore that /changeactionbar is also protected in combat. Therefore attempting to run that command in a non-secure context won't work if you're in combat, which the events you're using suggest you are.
  Reply With Quote
01-03-12, 04:22 AM   #3
Jonisaurus
An Aku'mai Servant
 
Jonisaurus's Avatar
Join Date: Aug 2011
Posts: 35
Originally Posted by Barjack View Post
I can't tell you if this is the most direct reason why it's not working (it may be due to a bug in RunSlashCmd or something--I didn't run that code nor do I really understand how it's supposed to work), but according to WoWPedia, ChangeActionBarPage() is protected when in combat. It stands to reason therefore that /changeactionbar is also protected in combat. Therefore attempting to run that command in a non-secure context won't work if you're in combat, which the events you're using suggest you are.
If the macro itself can change the action bar, can an addon running a macro through a slash command then also change the action bar or can't it?
I'm not that smart in these things.
  Reply With Quote
01-03-12, 05:04 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
It can but you need to utilize Secure Templates, either a SecureActionButtonTemplate if the actionbar swap is meant to happen on a click,
or a SecureStateHeaderTemplate if the swap is meant to happen on some condition (only conditions supported by the macro system are valid).

It's going to be a bit uphill for a new programmer as these while simple in concepts are not very beginner friendly constructs.

Edit: I should tell you upfront that some of the things you want to do are not possible (just looking at events).
You cannot take action through code when you're silenced or a cast succeeded or a cast failed etc.
That falls under automation and Blizzard has specifically disabled the ability for addons to make such decisions.
Only conditions supported by secure frames are these: Conditionals

Last edited by Dridzt : 01-03-12 at 12:28 PM.
  Reply With Quote
01-03-12, 05:06 AM   #5
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Keep in mind that some slash commands are only usable with hardware events, i.e. a macro can only run if you use a key to activate it, otherwise people would make addons to run macro code for them, it does not work.

I am not sure about changing action bar, but it may require hardware event to work... or?

But what is the idea? To avoid the bar from changing when pushing SHIFT+2 and such?
  Reply With Quote
01-03-12, 11:17 AM   #6
Jonisaurus
An Aku'mai Servant
 
Jonisaurus's Avatar
Join Date: Aug 2011
Posts: 35
Yes, it's obvious now that what I tried to do isn't possible.
I wanted to basically replace my stupid castsequence macro for Holy Fire / Smite with an addon that changes actionbars according to Holy Fire cooldown.

Unfortunately /castsequence doesn't allow spell queuing which is... ****.

As I'm short for keybindings and button space on my disc priest... is the /castsequence macro the ONLY way to combine the two abilities?
  Reply With Quote
01-03-12, 12:18 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,322
I have a lot of macros on my chars that combine 2 or more spells in a macro, something modified to your use would be something like this:
Code:
#showtooltip Holy Fire
/cast [mod] Holy Fire; Smite
This casts Smite on an unmodified run and casts Holy Fire if a modifier is held. It also makes sure it keeps displaying the cooldown and tooltip info for Holy Fire.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-03-12 at 12:20 PM.
  Reply With Quote
01-03-12, 12:30 PM   #8
Jonisaurus
An Aku'mai Servant
 
Jonisaurus's Avatar
Join Date: Aug 2011
Posts: 35
Originally Posted by SDPhantom View Post
I have a lot of macros on my chars that combine 2 or more spells in a macro, something modified to your use would be something like this:
Code:
#showtooltip Holy Fire
/cast [mod] Holy Fire; Smite
This casts Smite on an unmodified run and casts Holy Fire if a modifier is held. It also makes sure it keeps displaying the cooldown and tooltip info for Holy Fire.
Using it in Bartender so I dont need a macro just two keybindings, but thanks for trying to help

It's not so much that I can't watch out for the Holy Fire cooldown, it's more than I have to waste another keybind and a place for watching the CD on my UI for such a trivial task.
  Reply With Quote
01-12-12, 08:08 AM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Just a side note, use of slash commands from LUA has been completely broken as of the latest patch and no version of RunSlashCmd will work properly.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-12-12, 05:44 PM   #10
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
If you make a button that inherits from SecureActionButtonTemplate you can set attributes on it such as:

Code:
button:SetAttribute("alt-type1", "macro")
button:SetAttribute("macrotext", desiredMacroValue)
What this basically does is allows you to set a macro that will be executed when you alt-click the button. I use this in the addon Wholly to allow the addon to target a named NPC. The buttons get assigned their macro values dynamically.

This may allow you to get around using RunSlashCmd, but I have no idea whether the macros you want to use will be permitted.
  Reply With Quote
01-13-12, 12:43 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,322
That'll be fine as long as you don't try to change anything while in combat, secure templates lock down and their attributes cannot be changed then. Only by a secure handler and that's another mess to go through that doesn't yield any differing result.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Sending raw slash command.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off