Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: steptoe on Tue 10/04/2012 11:40:26

Title: SOLVED: Change ListBox ID after use
Post by: steptoe on Tue 10/04/2012 11:40:26
Hi

I am trying to change a ListBox ID Item.

Player has selected item "Windows"  from a ListBox and once used on a character the Listbox selected Item goes to ID 0 (which is just a "" entry).

I am using variables defined on selected ListBox items as well as Game.DoOnceOnly.

This variable is turned off once events have run.


An example:


function ListBox1_OnSelectionChanged(GUIControl *control)
{
 
String itemname = ListBox1.Items[ListBox1.SelectedIndex];
   
if (itemname == "Windows")
{
 Trunks=true;
}


This is repeated for 6 characters. Any item needs to be selected before you can use it on each character.

What would I need to do?

cheers

steptoe


Title: Re: Change ListBox ID after use
Post by: Khris on Tue 10/04/2012 12:11:48
I can't make heads or tails of your post I'm afraid.

As far as I understand what you're trying to do (allow the player to use a listbox item on a character), the ListBox's OnSelectionChanged function probably shouldn't change the game's state, as in, set or change variables.

If you want to remove the highlight, set ListBox1.SelectedIndex to -1.

If you want to react to the player selecting a listbox item, then clicking a character, you need the character's interact or anyclick event and check which item is selected in there.
Title: Re: Change ListBox ID after use
Post by: steptoe on Tue 10/04/2012 12:41:49
Cheers Khris

That does the trick  :)

steptoe