Listbox items to run script - SOLVED!

Started by Gepard, Sun 04/01/2009 22:27:29

Previous topic - Next topic

Gepard

I dont know if Im doing something wrong, but I dont want to bother Ghost with it anymore  ;D so I post it here:

I want to have a listbox where I can add and remove items (well I already have this). If I click on some of the items, a script will run (for example a msg will display). I know how to do this (barely) and it works. For example if I click on one a message will display saying "one", and if i click on two a msg will display saying "two" of course, but when I remove item one, item two takes its place and when i click on item two, its says "one" :f ) So... What I need is some "manual for a simple" that will tell me step by step what to do. Pleeeeeeease! Pretty please.

Thank you!
Drink up me 'arties! Yo ho!

RickJ

From what you describe it appears that you are displaying item's index number (i.e. it's location in the list) something like this:
Code: ags

     Display("You clicked on item number %d",MyList.SelectedIndex);


Perhaps what you want to do instead is to display the item's text like this
Code: ags

     Display("You clicked on item %s",MyList.Items[MyList.SelectedIndex]);


Gepard

#2
Yes, but I dont want just a display message after I click on the item, that was just an example. I want a script to run (for example a player to go to a different room or so). Basically Im looking for the complete script for: function listboxname_SelectionChanged(GUIControl *control)
Drink up me 'arties! Yo ho!

RickJ

Ok, so if you have a listbox named MyList and put 2 items in it, "one" and "two" you could just so something like the following
Code: ags

     if (MyList.Items[MyList.SelectedIndex]=="two") {
          TwoFunction();
     }
     else if (MyList.Items[MyList.SelectedIndex]=="one") {
          OneFunction();
     }

Gepard

Thank you thank you thank you! It works perfectly!
Drink up me 'arties! Yo ho!

SMF spam blocked by CleanTalk