Breaking the 18/256 Limit - FlexActions

18 macros/256 characters per are the limits we've grown accustomed to in WoW. Well, with FlexBar those are gone. FlexBar Scripts Editor allows editing scripts/macros as long as 10240 characters each. Further, if you put your code in functions and load them on the event 'ProfileLoaded' then your only limitation is 10240 characters per function. Also, with the new flexmacro/flexscript commands you can have as many macros as there are Button ID's.

RunScript and RunMacro: These two commands allow you to run a script or macro on any flexbar event. BE AWARE - this will NOT allow you to autocast spells. Spells will still only cast when you click a button. This is built into WoW by Blizzard to prevent bots. The only events on which spells will fire (AFAICT) are "LeftButtonClick", "RightButtonClick" and "BindingKeyUp".

The Script or Macro may be inline code (IE: script='OpenAllBags()' or macro='/dance') or the name of a script of macro saved in the scripts editor. Also, you may put multiline macros inline by putting them in brackets (IE: macro=['/dance' '/fbwait 20' '/bow']).

Example: A macro that will cast Raptor Strike if you have Aspect of Monkey up and Aspect of Monkey if you don't

Open the scripts editor and enter:

/if HasBuff("Aspect of Monkey")

/fbcast Raptor Strike

/else

/fbcast Aspect of Monkey

/end

Save this as 'My Raptor' then put the following on a macro button (standard macro button) /flexbar runmacro macro='My Raptor'.

FlexMacro and FlexScript: While using runscript/runmacro with "leftbuttondown" or "rightbuttondown" will simulate macros fairly well, it lacked two important features - a wide array of images for the buttons and the ability to follow a remap the way normal actions do. Enter FlexMacro and FlexScript. Like RunMacro and RunScript they run either inline macro/lua code or code from a saved script. Unlike the other two, they are attached to a button ID (not number) - remapping any button to that ID will get that flexaction's texture and action.

Example: Instead of using up one of WoW's 18 macros for the above example, I want it on ID 120 as a FlexMacro:

/flexbar FlexMacro ID=120 Texture='%macro120' Macro='My Raptor' Name='Raptor'

will create a macro on ID 120 with an Icon (number 120 on the icon selection pane of the WoW macro tool - I'll implement a GUI picker for this later) and an action of the macro we saved as 'My Raptor'

Another I use is:

/flexbar FlexScript ID=120 Texture='%backpack' Script='OpenAllBags()' Name='Bags'

to give me a button to toggle all my bags.

Special commands in FlexMacros:

In multiline macros executed through flexbar (runmacro/flexmacro/<macro> button in the editor) the following special commands are available. NOTE: These are ONLY available through these methods - standard WoW macros CANNOT use them.

/fbwait delay

Will wait delay tenths of a second before continuing execution. Note that this releases execution back to the UI so will not freeze your UI. Also note, you will NOT be able to use this to delay spellcasting - just doesn't work that way.

/if <condition>

/else

/end

Provides a single level (you CANNOT nest) very simple if/then/else construct. The condition is any condition you would use in if='<condition>' in a flexbar command. I implemented this as a simple means of testing my conditionals - it will likely not be greatly enhanced. If you need more than it can offer - go to lua.

/break

Terminates macro execution.

Special Commands for Any macros:

The infrastructure of FlexBar allowed me to implement several slash command very easily -- they were a few lines of code and a few minutes so I figured what the heck:

/fbdoin delay /command

will execute /command in delay tenths of a second. Note that you CANNOT delay spellcasts with this.

/fbcast spellname

This replaces /cast with the added feature that, if you don't specify a rank it uses the highest rank possible. /fbcast also casts pet spells. so /flexbar runmacro macro=['/fbcast Shadow Bolt' '/fbcast Firebolt'] will cause your imp to cast it's fire bolt while you cast your shadowbolt.

/fbuse itemname

This will use an item by name in your inventory.

/echo [#color] message

This will echo message above your head. The option color is the color you want it in, your choices are #green, #red, #blue, #yellow, #magenta, #cyan, #white.

/print [#color] message

This will display message in the chat box. Color is the same as echo.

Special considerations for Scripts:

Several functions are available in the FlexBar environment:

FB_CastSpellByName(spellname) has the same advantages as /fbcast

varname=Utility_Class:New() will give you access to :Print(msg,color), :Echo(msg,color) and TableCopy(tablevar) methods. Color can be any of the /echo or /print colors without the # on them or can be a table of RGB values. TableCopy returns a copy of the passed table to do copy by reference.

FBLastEvent and FBLastSource are global variables that will return the last event raised and the target that raised it.

FBTimers["timername"] = Timer_Class:New(delay, recurring, message, sound, callback) can be used to set a timer. See WoW_UtilityClass.lua for details.

Finally - I recommend that for any long scripts you encapsulate the code in a function, load the script on='ProfileLoaded' then just call the function from the runscript/flexscript commands. The reason being that the code has to be compile to byte-code, and this ensures it only goes through that once.