Bridge Commander Central
BC Forums => BC Scripting => Topic started by: Bat66wat6 on July 12, 2012, 01:07:24 PM
-
I am using the method below (not sure how many others there are) to add a button and define its event handler function; what gets called when button is clicked.
pMenu = Lib.LibEngineering.GetBridgeMenu("Tactical")
pButton = Lib.LibEngineering.CreateMenuButton("New button", "Tactical", __name__ + ".NewButtonHandler")
I've managed to disable the button using pButton.SetDisabled(1) but have not yet been able to find a function that will allow me to completely remove the button from the menu it was added to.
I want the button to be removed from the menu when I transport to another ship. The only thing i'm certain of at this point is that the game must allow for this functionality one way or another because transporting from a ship with say a cloaking device to one without a cloaking device magically removes the "Cloak on" "Cloak off" button and other similar ones where appropriate (Phasers etc) from the weapons display.
I've gone through almost all the SDK files but for my level of knowledge in the Totally Games created Python framework the function could be right in front of me and i'd never see it.
-
Check DS9FXMenuLib.py which is located in Custom\DS9FX\DS9FXLib there is a method which does what you want.
-
The mod you pointed me to wasn't on my machine so I had to go out and download the whole monster 700 MB for that one .py.
Anyways, i'm trying to use the DeleteButton function and (strangely) couldn't find any example of its use within any of the scripts in DS9FX. I threw the function into my script (with credits to its creators, of course) and used some guestimating and come up with calling the function as:
DeleteButton(pButton.GetName(), "Tactical")
The resulting error is:
File ".\Scripts\Custom\QBautostart\TheButton.py", line 577, in NewPlayerShip
DeleteButton(pButton.GetName(), "Tactical")
TypeError: STButton_GetName requires exactly 2 arguments; 1 given
Honestly, beyond knowing it's a "TypeError" type error i'm unsure as to the remedy. So I tried to cast the button object so it'd be able to use the .GetName() function and see if that did the trick:
pButton = App.STButton_Cast(pButton)
DeleteButton(pButton.GetName(), "Tactical")
It just left me with the same error :roll
-
import Lib.LibEngineering
...
pMenu = Lib.LibEngineering.GetBridgeMenu("Tactical")
pMenu.DeleteChild(pButton)
-
:yeahthat:
Thanks Defiant. That's exactly what I was after. :angel
*gives cookie*
-
You should have told me that you didn't have DS9FX. I'm used to people having it on their installs lol
The parameters it expects is the button caption IIRC.
-
My bad I guess. Whilst KM is great and there are so many cool things in it I just find the game to be less stable and just plain don't like the way ships have been balanced.
Meh, thanks. You can have a cookie for your time anyways :)
-
I always meant to have all the ships rebalanced but the crew helping me with that disappeared xD :P