Thread Tools Display Modes
08-23-06, 04:57 PM   #1
Tuller
A Warpwood Thunder Caller
 
Tuller's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 91
Bongos - Scripting

With WoW 2.0 (The Burning Crusade), things like showing, hiding, and moving action buttons in combat will most likely no longer work. In response to this, I have the scripting functionality from Bongos

Note: This thread is a work in progress. Ask questions

"I want to make another actionbar change when I change stances."
"I want to make an actionbar hide when I have no target."
"I want to make all bongos bars become transparent when I'm in town."
"I want to make <bar> do <action> when <event> happens."

With the release of Bongos 6.8.23, all of those things are now possible via scripting. Scripting is a feature intended for advanced users. You're going to want to know a bit about Lua, the WoW API, in game events, and the code of Bongos itself.


Writing a Script

Open up the options menu, and go to the scripts tab. You'll see three sections: bar, event, and action.

Bar - The barID we want listening for the event, or "all" for all bongos bars. You can figure out a bar's ID, if the bar is shown, by unlocking bar positions. bags is for the bag bar, 1 for the actionbar 1, menu for the menu bar, etc. You can also specify a group of bars, ex bags menu key for the menu, bags and key bars, and a range of bars, ex 1-10 for actionbars 1 through 10.
Event - What event we're watching for. A good list of events can be found at the wiki
Action - What we do when the specified event happens. This part is written in Lua. You have access to the normal globals for an event (event, arg1, arg2, etc), as well as the bar the event is being called for (bar).
Run At Load - This checkbox makes the given action run right after all bars have been created.
Saving - Click the save button. Code will only be saved if there were no errors in it.


Useful Bongos Stuff

bar
  • The bar a script is being run for.
  • A bar is a frame. You have access to all frame functions.
  • You can access a bar's ID via bar.id, or the function BBar.GetID(bar).

BBar - These functions work on all Bongos bars (action, class, bags, etc)
  • BBar.Show(bar [, save])
    • Shows the given bar.
    • If save is true, then save the bar's settings
  • BBar.Hide(bar [, save])
    • Hides the given bar.
    • If save is true, then save that the bar's hidden.
  • BBar.Toggle(bar [, save])
    • Show the bar if it's hidden, hide the bar if it's shown.
    • If save is true, then save its new setting.
  • BBar.Lock(bar)
    • Stops the given bar from moving, and hides its drag frame.
  • BBar.Unlock(bar)
    • Lets the given bar move, shows its drag frame.
  • BBar.SetScale(bar [, scale [, save]])
    • Sets the bar's scale.
    • This is different than frame:SetScale(scale) in that the top left position of the bar should remain constant
    • Prevents the drag frame's scale from changing.
  • BBar.SetAlpha(bar [, alpha [, save]])
    • Sets the bar's opacity.
    • This is different than UIObject:SetAlpha(alpha) in that the drag frame for any given bar will not become completely transparent.
  • BBar.GetID(bar)
    • Returns the barID of a given bar.
  • BBar.IDToBar(barID)
    • Takes a barID, ex menu, bags, or pet, and returns its related bar.
  • BBar.ForAll(action, arg1, arg2, ...)
    • Does action(bar, arg1, arg2, ...) to every bongos bar
    • If you wanted to say, make every bar transparent, you could do BBar.ForAll(BBar.SetAlpha, 0.5)

BActionBar - These functions only work on action bars.
  • BActionBar.SetStanceOffset(barID, offset)
    • Switches a bar's page to barID + offset
    • It will not switch pages if you're manually paged (shift + number)
    • So, BActionBar.SetStanceOffset(2, 1) would change the second actionbar to have the same buttons as the third actionbar.
  • BActionBar.SetContextOffset(barID, offset)
    • Switches a bar's page to barID + offset
    • It will not switch pages if you're manually paged (shift + number), and also not in a stance
    • So, BActionBar.SetContextOffset(2, 1) would change the second actionbar to have the same buttons as the third actionbar.

BProfile - These functions are used for loading and saving Bongos layouts. I don't have an exact time, but I would suggest not frequently loading profiles
  • BProfile.Load(profileName)
    • Loads the given Bongos layout, if it exists.
  • BProfile.GetDefault()
    • Returns the name of the default profile, if one exists.

BScript - These functions are used to define event actions for Bongos completely in Lua.
  • BScript.AddEventAction(event, action [, runNow])
    • Adds a function for Bongos to run on the given event.
    • Any event can have multiple functions. These are called in the order they were added
    • When the event is called, the function that is being called is passed to the function, but not currently the event being called (note to self: Do that)
    • If runNow is true, then the event action will be run immediately after being saved.
  • BScript.AddStartupAction(action [, runNow])
    • Adds an event action to run right after all addons have been loaded.
    • Right now, its equivalent to BScript.AddEventAction("VARIABLES_LOADED", action [, runNow])
  • BScript.AddBarEventAction(barList, event [, action [, runNow]])
    • Adds an event action to be run for the given barList.
    • A bar list can be a single barID, ex class, a set of barIDs, ex class pet bags, a range of barIDs, ex 1-10, or all for all bars
    • Does not run if no bars currently exist in the given barList.
    • Currently, you can only have one action per bar event
    • If runNow is true, then the action will be run for the bar immediately after being saved.
    • When run, the action is passed both the event and bar, ex action(event, bar)
  • BScript.RemoveEventAction(event, action)
    • Removes the given action from the list of things to run when the given event happens.
  • BScript.RemoveEventForBar(event, barList)
    • Removes any event actions for all barIDs in the given barList on the given event
  • BScript.CallEvent(event)
    • Runs all event scripts for the given event
  • BScript.CallBarEvent(event)
    • Runs all bar event scripts for the given event
  • BScript.CallBarEventForBar(event, barList)
    • Triggers the bar event script for all barIDs in the given barList


Examples

Making the second actionbar switch when you shapeshift/change stances:
Code:
bar:      2
event:   UPDATE_BONUS_ACTIONBAR
action:
BActionBar.SetStanceOffset(bar.id, GetBonusBarOffset())
Make the first actionbar hide when you don't have a target:
Code:
bar:      1
event:   PLAYER_TARGET_CHANGED
action:
if UnitExists("target") then
    bar:Show()
else
    bar:Hide()
end
Run at Load:  Checked
Make the tenth bar transparent when in combat. This one requires two scripts, one for entering combat, and one for leaving combat:
Code:
bar:      10
event:   PLAYER_REGEN_DISABLED
action:
BBar.SetAlpha(10, 0.5)
Run at Load:  Checked
Code:
bar:      10
event:   PLAYER_REGEN_ENABLED
action:
BBar.SetAlpha(10, 1)
Run at Load:  Checked

Last edited by Tuller : 10-29-06 at 01:53 PM.
  Reply With Quote
08-25-06, 09:59 PM   #2
Khuas
A Kobold Labourer
Join Date: Aug 2006
Posts: 1
This is beautiful, Tuller.

Please bear with me as I'm a newb at this and don't have access right now to my WoW machine.

With the examples you list, are the functions SetStanceOffset(), Show() and Hide() specific to Bongos or are they Blizz/WoW functions? I don't see them at the Wiki but then I might not be looking in the right place.

If they are Bongo specific, do you have a list of functions available?

In the second example with the target/hide, I know that bar is a reference to the bar the event has occurred on - are there other globals you have available for use here?

Again, forgive me if my questions are dumb, just started replaying WoW after a year off and probably trying to learn too much at a time.
  Reply With Quote
08-25-06, 11:41 PM   #3
shadowknight456
A Defias Bandit
Join Date: Aug 2006
Posts: 2
Nice, this is one thing i was lookin to use in Bongos, but i was wondering if instead of just hiding the bar, i could changes it's transperancy?
  Reply With Quote
08-25-06, 11:57 PM   #4
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
Originally Posted by shadowknight456
Nice, this is one thing i was lookin to use in Bongos, but i was wondering if instead of just hiding the bar, i could changes it's transperancy?
should be able to use http://www.wowwiki.com/API_UIObject_SetAlpha
  Reply With Quote
08-26-06, 12:12 AM   #5
shadowknight456
A Defias Bandit
Join Date: Aug 2006
Posts: 2
Originally Posted by brotherhobbes
Yay! It works, but (i know, i have too many questions )if i could make it so when my health is below a certain percent it shows the bar, also, instead of having a target it would set the alpha, when i enter /leave combat it would change the alpha, i almost got it to work, but it wouldnt switch back when i went out of combat, if i could have some help that would be awesome!

Last edited by shadowknight456 : 08-26-06 at 10:12 AM.
  Reply With Quote
08-26-06, 10:32 AM   #6
Tuller
A Warpwood Thunder Caller
 
Tuller's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 91
Whenever an event occurs, you have access to:
  • bar - What bar the event is being fired for
  • event - What event is being fired
  • Any args an event has. You can figure out what these are by looking at the events list

With the examples you list, are the functions SetStanceOffset(), Show() and Hide() specific to Bongos or are they Blizz/WoW functions? I don't see them at the Wiki but then I might not be looking in the right place.
Show() and Hide() are frame functions
Bongos functions will look like BBar.Funct, or BActionBar.Funct. I'll end up making a list of the useful ones soonish.

if i could make it so when my health is below a certain percent it shows the bar, also, instead of having a target it would set the alpha, when i enter /leave combat it would change the alpha, i almost got it to work, but it wouldnt switch back when i went out of combat, if i could have some help that would be awesome!
For health, you need to use the event UNIT_HEALTH. Scroll down a bit to find the event.
For combat, you need to make two scripts: One that fires on PLAYER_REGEN_DISABLED (in combat), PLAYER_REGEN_ENABLED (out of combat)

Last edited by Tuller : 08-26-06 at 10:40 AM.
  Reply With Quote
09-03-06, 03:46 AM   #7
foxpur
A Murloc Raider
Join Date: Aug 2006
Posts: 4
Scripting

Druid issue:

Bar 1 = normal
Bar 2 = Cat form commands
Bar 3 = Bear form commands

Using
Code:
bar:      1
event:   UPDATE_BONUS_ACTIONBAR
action:
BActionBar.SetStanceOffset(bar.id, GetBonusBarOffset())
I managed to make it so that Bar 1 swapped out for bar 2 when I changed to Cat form, nice, works like a dream. But, when I change to Bear form that doesn't work because bar 3 is not the offset...

So how do I script in the change so that Cat form gets bar 2 (like it does now) and Bear form gets bar 3 (and for those in Moonkin I would assume they also need an additional bar).

Haven't tested this yet but:

Code:
 
If GetShapeshiftFormInfo(3) then
   BActionBar.SetStanceOffset(bar.id, GetBonusBarOffset())
else
   BActionBar.SetStanceOffset(1,3)
However, my idea there doesn't take into account Moonkin form. I think that code is along the idea of what I am looking for...

Just for reference for other people TRYING try write thier own code bits:

relates to the different forms:

Druid

* 1 = Bear/Dire Bear Form
* 2 = Aquatic Form
* 3 = Cat Form
* 4 = Travel Form
* 5 = Moonkin Form

Rogue

* 1 = Stealth

Warrior

* 1 = Battle Stance
* 2 = Defensive Stance
* 3 = Beserker Stance

Last edited by foxpur : 09-03-06 at 04:23 AM.
  Reply With Quote
09-03-06, 05:20 AM   #8
Haraald
A Defias Bandit
Join Date: Sep 2006
Posts: 2
Code:
event: PLAYER_AURAS_CHANGED
action:
if UnitHasBuff("Shadowform") then
    BActionBar.SetStanceOffset(bar, 6)
else
    BActionBar.SetStanceOffset(bar, 0)
end
Run on Load:  checked
Thank you very much, Tuller !
I'll try it as soon as possible !
  Reply With Quote
09-06-06, 11:44 AM   #9
Nahkohe
A Deviate Faerie Dragon
Join Date: Aug 2005
Posts: 14
Shadowform

I tried this but couldn't get it to work. However, changing UnitHasBuff to IsBuffActive is all it needs to make it work. I'm not sure what I was doing wrong with the posted script but this works for me.

Nahkohe

Originally Posted by Haraald
Code:
event: PLAYER_AURAS_CHANGED
action:
if UnitHasBuff("Shadowform") then
    BActionBar.SetStanceOffset(bar, 6)
else
    BActionBar.SetStanceOffset(bar, 0)
end
Run on Load:  checked
Thank you very much, Tuller !
I'll try it as soon as possible !
  Reply With Quote
09-19-06, 10:51 AM   #10
Siven
A Deviate Faerie Dragon
Join Date: Feb 2005
Posts: 11
So, For my warrior would this change bar 2, to bar 3 only when im in Defensive stance, and chang back to bar 2 when in battle/zerk stance ?


If GetShapeshiftFormInfo(2) then
BActionBar.SetStanceOffset(bar.id, GetBonusBarOffset())
else
BActionBar.SetStanceOffset(2,1)
  Reply With Quote
09-21-06, 04:13 AM   #11
Namtabmai
A Kobold Labourer
Join Date: Sep 2006
Posts: 1
Hi, I guess I'm another person looking to switch away from flexbar to bongos.
I use flexbars to create a representation of my keyboard, so I have a 4x4 block of icons that are mapped to a 4x4 part of the keyboard. I have this 4x4 block change depending if I'm stealthed or not but the key binding remain the same.

For example the top right icon would be mapped to 'T' and unstealthed would be Kick and stealthed would be Garrote.

Is this sort of functionality available in bongos? If so which options should I be looking at?
  Reply With Quote
09-23-06, 08:42 AM   #12
Hety
A Defias Bandit
Join Date: Sep 2006
Posts: 2
Hey.

I just got my Zandalarian Hero Charm and plan to using it the problem is that i always miss the time cooldown expires. What i want to do is to put on BIG button the middle of screen that will show when the timer expires and hide when it on CD again.

I made a bar with 1 button on it(bar number 5).

And started with eay thing. Disabling Bar when CD starts.
Code:
bar: 5
event: ACTIONBAR_UPDATE_COOLDOWN
action:
if bar:IsShown() then
    bar:Hide()
else
    bar:Show()
end

ACTIONBAR_UPDATE_COOLDOWN should trigger every time CDstarts or stops on bar. Then if the bar is shown(default) it will be hidden(licked talisman, got buff, waiting for CD). Then when CD ends if the bar is hidden it will be shown.

Still this one does not work. The bar does not even diappear. Any ideas?
  Reply With Quote
09-23-06, 11:41 AM   #13
behkat
A Defias Bandit
Join Date: Sep 2006
Posts: 3
Originally Posted by Hety
Code:
bar: 5
event: ACTIONBAR_UPDATE_COOLDOWN
action:
if bar:IsShown() then
    bar:Hide()
else
    bar:Show()
end
I'm trying to do the same thing for my cooldown spells and what I've discovered is that ACTIONBAR_UPDATE_COOLDOWN isn't fired when the cooldown ends. I haven't yet found an event that is, so I think I'll have to build an OnUpdate handler for the bar to check the cooldown state.
  Reply With Quote
09-23-06, 02:43 PM   #14
schmoli
A Kobold Labourer
Join Date: Sep 2006
Posts: 1
I'm trying to get a mouseover script on bar6 and it's just not working.

Bar: 6
Event: MouseIsOver
if (MouseIsOver(BBar.IDToBar(6))) then
BBar.SetAlpha(bar, 1)
else
BBar.SetAlpha(bar, 0)
end


i'm thinking it's my event or something? if i swap the 1 and the 0, it will make the alpha 0 immediately, it's just not making it show on hover.
  Reply With Quote
09-23-06, 11:01 AM   #15
Tuller
A Warpwood Thunder Caller
 
Tuller's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 91
I had before flexbar with the commands gainpet and losepet to show/hide it, but in the Events is only a PET_BAR_UPDATE and I don't know how to script it
Code:
if UnitExists("pet") then
show bar
else
hide bar
end
Originally Posted by Siven
So, For my warrior would this change bar 2, to bar 3 only when im in Defensive stance, and chang back to bar 2 when in battle/zerk stance ?
Code:
If GetShapeshiftFormInfo(2) then
   BActionBar.SetStanceOffset(bar.id, GetBonusBarOffset())
else
   BActionBar.SetStanceOffset(2,0)
end
That should be the right code.

Code:
bar:    5
event: ACTIONBAR_UPDATE_COOLDOWN
action:
if bar:IsShown() then
    bar:Hide()
else
    bar:Show()
end
That event is triggered whenever a cooldown on any bar changes. You can then check if a cooldown is up for a given button by using the function GetActionCooldown(slot). You can figure out what slot is by checking the name of the button in the keybindings menu. It'll be the number part

I have this 4x4 block change depending if I'm stealthed or not but the key binding remain the same. Is this sort of functionality available in bongos? If so which options should I be looking at?
You shouldn't require scripting for doing this for just the first actionbar, as it should already change when stealthing. Change the number of bars so that the max size for the first one will be 16. I should make the sizing option a bit more intuitive than it is.

Last edited by Tuller : 09-23-06 at 11:05 AM.
  Reply With Quote
09-23-06, 11:38 AM   #16
Hety
A Defias Bandit
Join Date: Sep 2006
Posts: 2
I did few tests with ACTIONBAR_UPDATE_COOLDOWN. It triggers when CDstarts. But it does not when it ends. So dont .._UPDATE_STATE and .._UPDATE_USABLE. What event should be there to triggerat end of CD?
  Reply With Quote
09-24-06, 03:01 AM   #17
elvenn
A Defias Bandit
Join Date: Sep 2006
Posts: 2
Thumbs up

EDIT: ok i fixed my code. SuperMacro mod was causing it not to work.

Code:
BAR:3
EVENT: UPDATE_BONUS_ACTIONBAR
if GetBonusBarOffset() == 1 then BActionBar.SetStanceOffset(bar.id, 2)
elseif GetBonusBarOffset() == 2 then BActionBar.SetStanceOffset(bar.id, 0)
elseif GetBonusBarOffset() == 3 then BActionBar.SetStanceOffset(bar.id, 6) end
RUN AT LOAD: Checked

BAR:4
EVENT: UPDATE_BONUS_ACTIONBAR
if GetBonusBarOffset() == 1 then BActionBar.SetStanceOffset(bar.id, 2)
elseif GetBonusBarOffset() == 2 then BActionBar.SetStanceOffset(bar.id, 0)
elseif GetBonusBarOffset() == 3 then BActionBar.SetStanceOffset(bar.id, 6) end
RUN AT LOAD: Checked

what i want to happen is

enter defensive stance:
bar3 offsets to self
bar4 offsets to self

enter battle stance:
bar3 offsets to 5
bar4 offsets to 6

enter berserker stance:
bar3 offsets to 9
bar4 offsets to 10

Last edited by elvenn : 09-24-06 at 06:06 AM.
  Reply With Quote
09-24-06, 04:52 AM   #18
Grumpey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 5
I got this to work on my druid this morning to change bars when I went to cat form.

Instead of Player Aura's, I changed to UPDATE_BONUS_ACTIONBAR for the event

_,_,active = GetShapeshiftFormInfo(3)

if (( active == 1 )) then
BActionBar.SetStanceOffset(2,1)
else
BActionBar.SetStanceOffset(2,0)
end
  Reply With Quote
09-24-06, 07:59 AM   #19
keltren
A Kobold Labourer
Join Date: Apr 2006
Posts: 1
Hya,
I'm pretty new to all this but first off I have to say that I really like bongos :-)

Right now I'm trying to get a script to work for my hunter, the idea is to have the "Mongoose Bite" Button pop up when it becomes usable.

Bar: 6
Event: SPELL_UPDATE_USABLE
Action:
if IsUsableAction(61) then
bar:Show()
else
bar:Hide()
end

Run at Load:checked

This basically seems to work (the button does indeed pop up), but it remains visible even after clicking it (until about 3/4 through it's cooldown, when it disapears)
Any ideas how to work around this? Maybe I'm doing something fundamentally wrong here...I'm still a complete noob at this ;-)
  Reply With Quote
09-24-06, 12:37 PM   #20
Grumpey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 5
I was playing with something like this for stance shifting, I briefly checked this on my druid and it worked, but I'm not sure how practical it is to do mass bar changes on shapeshift/stance changes.

Bar all
Event: UPDATE_BONUS_ACTIONBAR

Code:
for i=1,3 do
	_,_,active = GetShapeshiftFormInfo(i)
	if (( active == 1 )) and (( i == 1 )) then
		--Stance 1
		BActionBar.SetStanceOffset(2,1)
		--Break to exit loop since you can only be in one stance at a time
		break
	elseif (( active == 1 )) and (( i == 2 )) then
		--Stance 2
		BActionBar.SetStanceOffset(2,3)
		BActionBar.SetStanceOffset(1,2)
		--Break to exit loop since you can only be in one stance at a time
		break
	elseif (( active == 1 )) and (( i == 3 )) then
		--Stance 3
		BActionBar.SetStanceOffset(2,4)
		BActionBar.SetStanceOffset(1,1)
		--Break to exit loop since you can only be in one stance at a time
		break
	else
		--return bars to normal
		BActionBar.SetStanceOffset(2,0)
		BActionBar.SetStanceOffset(1,0)
		
	end
end
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Released AddOns » Bongos - Scripting


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