mad rabbit 0 Posted January 22, 2004 I am learning how to write scripts in OFP the steep, nasty, hard way (at least for me)....with a CTI map. I'm starting to understand what does what and what goes where I think. I have managed to edit the description.ext so that 2 new buttons are now present within an exisiting dialog, and that one has budged over to make space for these 2 new ones. However I would like to hide these buttons (i.e. make their actions unavailable) until needed (i.e. an upgrade is purchased). My question is: 1) What would an external script contain so that these two buttons stay hidden/not appear in the default dialog until the I execute the particular script? Additional Q: 2) How would I make these buttons then disappear if a certain criteria was not met? 3) Do I need to make another description.ext so that these buttons appear along with everything else being re-initialized everytime the dialog is opened after the upgrade has been purchased OR Is there a way to add these buttons by making a pseduo-description.ext that preserves the original dialog from the base description.ext but adds the new buttons specified within therefore avoiding what I believe to be extra work+problems with re-initialization of a different description.ext? I have read Vektorboson's Dialog Tutorial and I think it would require something along the lines of: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ok = createDialog "BuyM101Button" Please help this NOOB! The following is an extract from the description.ext I have edited with the buttons I want to hide/show being the last two: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class ControlMenu:DefaultMenu { controls[] = {MenuTitle,InfoBox,UpgradeStatusLabel,TeamLabel,TeamList,UpgradeLabel,UpgradeList,UnitLabe l,UnitList,LightLabel,LightList,HeavyLabel,HeavyList,AirLabel,AirList,ExitButton,BuyM101Bu tton,BuyM270Button}; controlsBackground[] = {ControlBackgroundWindow}; class ControlBackgroundWindow:GuiText { colorBackground[] = {0.35,0.35,0.35,0.85}; text = ""; x = 0.05625; y = 0.075; w = 0.8925; h = 0.7; }; class MenuTitle:GuiLargeText { style = GUICENTER; idc = IDCMENUTITLE; x = 0.3; y = 0.05; w = 0.4; h = 0.08; text = $STRCONTROLCENTER; }; class InfoBox:GuiList { idc = IDCCONTROLMENUINFO; type = GUILIST; x = 0.065; y = 0.125; w = 0.215; h = .08; }; class UpgradeStatusLabel:GuiText { style = GUICENTER; idc = IDCMENUSTATUSLABEL; x = 0.25; y = 0.125; w = 0.435; text = ""; }; class TeamLabel:GuiText { style = GUIRIGHT; x = 0.63; y = 0.125; w = 0.09; text = $STRTEAM; }; //Drop down list of teams. class TeamList:GuiComboBox { idc = IDCCONTROLMENUTEAMLIST; x = 0.725; y = 0.125; w = 0.215; h = 0.04; }; class UpgradeLabel:GuiButton { x = 0.63; y = 0.175; w = 0.09; text = $STRUPGRADE; action = "controlCenterMenuUpgrade = true"; }; //Drop down list of upgrades. class UpgradeList:GuiComboBox { idc = IDCCONTROLMENUUPGRADELIST; x = 0.725; y = 0.175; w = 0.215; }; class UnitLabel:GuiButton { x = 0.065; y = 0.225; w = 0.215; text = $STRADDTOTEAM; action = "controlCenterMenuUnit = true"; }; //Drop down list of soldiers. class UnitList:GuiListBox { idc = IDCCONTROLMENUUNITLIST; x = 0.065; y = 0.275; w = 0.215; h = 0.4375; }; class LightLabel:GuiButton { x = 0.285; y = 0.225; w = 0.215; text = $STRADDTOTEAM; action = "controlCenterMenuLight = true"; }; //Drop down list of light vehicles. class LightList:GuiListBox { idc = IDCCONTROLMENULIGHTLIST; x = 0.285; y = 0.275; w = 0.215; h = 0.4375; }; class HeavyLabel:GuiButton { x = 0.505; y = 0.225; w = 0.215; text = $STRADDTOTEAM; action = "controlCenterMenuHeavy = true"; }; //Drop down list of heavy vehicles. class HeavyList:GuiListBox { idc = IDCCONTROLMENUHEAVYLIST; x = 0.505; y = 0.275; w = 0.215; h = 0.4375; }; class AirLabel:GuiButton { x = 0.725; y = 0.225; w = 0.215; text = $STRADDTOTEAM; action = "controlCenterMenuAir = true"; }; //Drop down list of aircraft. class AirList:GuiListBox { idc = IDCCONTROLMENUAIRLIST; x = 0.725; y = 0.275; w = 0.215; h = 0.4375; }; //Exit Control Menu button. class ExitButton:GuiButton { x = 0.725; y = 0.725; w = 0.215; text = $STREXIT; action = "closeDialog 0"; }; //M101 Towed Howitzer Menu button. class BuyM101Button:GuiButton { x = 0.285; y = 0.725; w = 0.215; text = $STRBUYM101; action = "controlCenterMenuCoCUAArtilleryM101 = true"; }; //M270 MLRS Menu button. class BuyM270Button:GuiButton { x = 0.505; y = 0.725; w = 0.215; text = $STRBUYM270; action = "controlCenterMenuCoCUAArtilleryM270 = true"; }; }; Thanks again and please tell me if some of my concepts about OFP editing are a bit warped. Share this post Link to post Share on other sites
Spinor 0 Posted January 23, 2004 Hi, the scripting commandyou are looking for is ctrlShow[idc,show] where idc is the ID number of the button (or any other dialog element) and show can be either true (to make visible) or false (to hide). idc is a unique number with which to identify dialog elements. Every button/text/etc. you want to deal with via scripting needs one. It is defined in the description.ext, e.g. your two buttons would look like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//M101 Towed Howitzer Menu button. class BuyM101Button:GuiButton { idc = 501; x = 0.285; y = 0.725; w = 0.215; text = $STRBUYM101; action = "controlCenterMenuCoCUAArtilleryM101 = true"; }; //M270 MLRS Menu button. class BuyM270Button:GuiButton { idc = 502; x = 0.505; y = 0.725; w = 0.215; text = $STRBUYM270; action = "controlCenterMenuCoCUAArtilleryM270 = true"; }; }; The IDs can be any integer number, just make sure they are unique. Be sure that there are no conflicts with the other IDs in your example which are defined with placeholders like  "idc = IDCCONTROLMENUUPGRADELIST;" To hide the buttons you can then use: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ctrlShow[501,false];  ctrlShow[502,false] If you want the buttons to be hidden when launching the dialog, you have to insert these commands right after the appropriate createDialog command which should look like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ok = createDialog "ControlMenu" Just to make sure of a few things: - You can only have one description.ext in your mission folder. All dialogs etc. must be defined within that (there is exception: you may have dialog definitions within addons, but this must also be linked to within the description.ext). -The createDialog command is only used to display dialogs (consisting of buttons, listboxes, etc.) and not single elements like a button, hence your example usage should not work. Hope this helps, Spinor PS Make sure to take a look at the Command Reference. Besides ctrlShow, there are a host of other commands for manipulating buttons,etc., e.g. with ctrlSetText you can change the text. Share this post Link to post Share on other sites
mad rabbit 0 Posted January 23, 2004 WOW, that was quick! Thanks for all your help Spinor especially for including the description.ext into the example you presented. Share this post Link to post Share on other sites