Home   Help Search Login Register  

Author Topic: Getting an output from a dialog's ComboBox  (Read 690 times)

0 Members and 1 Guest are viewing this topic.

Offline Gogs

  • Contributing Member
  • **
  • WWIIEC - Gracefully retired boss
Getting an output from a dialog's ComboBox
« on: 16 Oct 2005, 17:59:13 »
Hello all. Been doing a little playing with dialog boxes recently, and I'm rapidly getting the hang of it. In particular, Razorwings' OFP Dialog Maker is an awesome tool. The problem I'm having is getting the dialog box to do anything based on differing inputs from a combo box. Say I created my dialog box from a script with this in it....

Quote
_ok = createDialog "Chooseaircraft"
?(!_ok): hint "Error"; exit

_index = lbAdd [102, "1st Aircraft"]
lbSetData [102, _index, "1st Aircraft"]
_index = lbAdd [102, "2nd Aircraft"]
lbSetData [102, _index, "2ndAircraft"]
_index = lbAdd [102, "3rd Aircraft"]
lbSetData [102, _index, "3rd Aircraft"]
lbSetCurSel [102, 0]

There are more lists than that, but they are all made in the same way. Now, I'm a little unsure about this whole "_index" nonsense. Is that labeling the data 0, 1 and 2, or what? Anyhow, I go on to define my dialog in the description.ext. Now, the relevant section regarding the list box is as follows......

Quote
class ChooseAircraft : RscCombo
 {
  x = 0.2
  y = 0.14997
  idc = 102
  w = 0.3
  h = 0.037
  style = ST_LEFT
  colorText[] = {0.2, 0.2, 0.2, 1};
  colorBackground[] = {0.4, 0.4, 0.4, 1};
 font = "CourierNewB64"
  SizeEX = 0.025
  colorSelect[] = {0.4, 0.4, 0.4, 1};
  colorSelectBackGround[] = {0.2, 0.2, 0.2, 1};
  RowHeight = 0.04
 wholeHeight = 0.3
  };

Thats all just position and colour stuff so far as I can tell, the important bit being the idc, which matches the idc in the script used to call the dialog. Finally, and herein lies the problem, I wan't to USE what the player has put as an output. Now, I tried something along those lines when clicking a button....

Quote
action = "if ((lbCurSel 102)==0) then hint ""Aircraft1"";"

Basically, all I need is to squeeze a number based output from the list, so when the button is pressed, dependant on the number, different things happen. I'm all cool on the actions, I just need to get the combo box to give me a number. Can anybody give me the command and syntax? Your help would be MUCH appreciated. Thanks a lot.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Getting an output from a dialog's ComboBox
« Reply #1 on: 16 Oct 2005, 22:35:51 »
the simple answer to all that is yes :P

basically lbCurSel idc_number will return a number from 0 to however many fields there are. so, if you put something along the lines of

Code: [Select]
_selected = lbCurSel idc_number
then _selected will hold the appropriate number. you just need to match that to your list and away you go. the reason your hint line may not be working is all the double quotes, depending on what version of flashpoint you have... try using {} instead.

in my humble opinion, if you're doing a heap of things depending on the player's choice, point the action at a script to deal with it instead of trying to script it within the description.ext file.

Offline Gogs

  • Contributing Member
  • **
  • WWIIEC - Gracefully retired boss
Re:Getting an output from a dialog's ComboBox
« Reply #2 on: 17 Oct 2005, 00:06:46 »
Alright Bro, will do. Thanks a lot. Might get a bit of scripting involved. Question.... if I use my script to work out something, then want to feed back into my dialog and do say ctrlSetText something in it based on the options I picked, will it update the dialog from the script rather than the description, if you follow?

Offline Gogs

  • Contributing Member
  • **
  • WWIIEC - Gracefully retired boss
Re:Getting an output from a dialog's ComboBox
« Reply #3 on: 17 Oct 2005, 00:25:50 »
Don't answer that. Found out for myself. Shes working a beauty. Thanks very much for your help. :D