As for the button:
import App
# if you have scripts\Lib\LibEngineering.py(c)
import Lib.LibEngineering
def init():
Lib.LibEngineering.CreateMenuButton("The name of your button", "Tactical", __name__ + ".disableAllEngines")
# else (i dont' know if it is part of stock bc):
def init():
pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
if not pTacticalControlWindow:
print "Error: No Tactical Control Window"
return None
pDatabase = App.g_kLocalizationManager.Load("data/TGL/Bridge Menus.tgl")
pMenu = pTacticalControlWindow.FindMenu(pDatabase.GetString("Tactical"))
App.g_kLocalizationManager.Unload(pDatabase)
ET_EVENT = App.Mission_GetNextEventType()
pMenu.AddPythonFuncHandlerForInstance(ET_EVENT, __name__ + ".disableAllEngines")
pEvent = App.TGIntEvent_Create()
pEvent.SetEventType(ET_EVENT)
pEvent.SetDestination(pMenu)
pEvent.SetInt(EventInt)
pButton = App.STButton_CreateW(App.TGString("The name of your button"), pEvent)
pMenu.PrependChild(pButton)
# in both cases:
def disableAllEngines(pObject, pEvent):
pPlayer = App.Game_GetCurrentPlayer()
pSet = pPlayer.GetContainingSet()
ObjTuple = pSet.GetClassObjectList(App.CT_SHIP)
if ObjTuple:
for pShip in ObjTuple:
if pShip:
pShip.ClearAI()
pObject.CallNextHandler(pEvent)
you do the same as MLeo said only that you type into the console
init()instead of
from <<YourChosenNameHere>> import *
If you have QBautostart installed place the script into scripts/Custom/QBautostart and the button wil be loaded automatically when you start QB.
NOTE: the code in the second init method is a copy of some code in LibEngineering so I'm not the autor, i only changed some variables!