Any help would be really appreciated.
Help with ds_lists
#1
Posted 05 March 2012 - 12:54 AM
Any help would be really appreciated.
#2
Posted 05 March 2012 - 01:41 AM
For example, if your ds_list is stored in the variable called "cards", then you can do this:
/* Build the menu string */
displayString = "";
for (p=0; p<ds_list_size(cards); p+=1) {
spr = ds_list_find_value(cards, p);
displayString += sprite_get_name(spr);
if (p < ds_list_size(cards) - 1) { spr+="|"; }
}
selected = show_menu(displayString);
/* Get the selected sprite */
selectedSprite = ds_list_find_value(cards, selected);Voila
-IMP
#3
Posted 05 March 2012 - 02:01 AM
All you need to do is use the sprite_get_name() function to display the name in the menu, but use the actual sprite index everywhere else.
For example, if your ds_list is stored in the variable called "cards", then you can do this:/* Build the menu string */ displayString = ""; for (p=0; p<ds_list_size(cards); p+=1) { spr = ds_list_find_value(cards, p); displayString += sprite_get_name(spr); if (p < ds_list_size(cards) - 1) { spr+="|"; } } selected = show_menu(displayString); /* Get the selected sprite */ selectedSprite = ds_list_find_value(cards, selected);
Voila.
-IMP
Thank you it's so close to working! The only problem is that it's bundling all the sprites together as one value as in it's not detecting the "|" between them. ): Do you know why this is happening? Thank you, it's so close to finally working I just need to get this one thing fixed.
(Idk if it had anything to do with it but I added a -1 as the default value for the show_menu since a default value was missing.)
Edited by Arthur Yarbrough, 05 March 2012 - 02:05 AM.
#4
Posted 05 March 2012 - 02:10 AM
Sorry; I clearly wasn't proofreading well enough. Where I have spr+="|", it should be displayString+="|" because it's displayString that's being used for the menu, not spr.
All you need to do is use the sprite_get_name() function to display the name in the menu, but use the actual sprite index everywhere else.
For example, if your ds_list is stored in the variable called "cards", then you can do this:/* Build the menu string */ displayString = ""; for (p=0; p<ds_list_size(cards); p+=1) { spr = ds_list_find_value(cards, p); displayString += sprite_get_name(spr); if (p < ds_list_size(cards) - 1) { spr+="|"; } } selected = show_menu(displayString); /* Get the selected sprite */ selectedSprite = ds_list_find_value(cards, selected);
Voila.
-IMP
Thank you it's so close to working! The only problem is that it's bundling all the sprites together as one value as in it's not detecting the "|" between them. ): Do you know why this is happening? Thank you, it's so close to finally working I just need to get this one thing fixed.
(Idk if it had anything to do with it but I added a -1 as the default value for the show_menu since a default value was missing.)
And, yes, the default value can be anything you want.
-IMP
#5
Posted 05 March 2012 - 02:31 AM
Sorry; I clearly wasn't proofreading well enough. Where I have spr+="|", it should be displayString+="|" because it's displayString that's being used for the menu, not spr.
All you need to do is use the sprite_get_name() function to display the name in the menu, but use the actual sprite index everywhere else.
For example, if your ds_list is stored in the variable called "cards", then you can do this:/* Build the menu string */ displayString = ""; for (p=0; p<ds_list_size(cards); p+=1) { spr = ds_list_find_value(cards, p); displayString += sprite_get_name(spr); if (p < ds_list_size(cards) - 1) { spr+="|"; } } selected = show_menu(displayString); /* Get the selected sprite */ selectedSprite = ds_list_find_value(cards, selected);
Voila.
-IMP
Thank you it's so close to working! The only problem is that it's bundling all the sprites together as one value as in it's not detecting the "|" between them. ): Do you know why this is happening? Thank you, it's so close to finally working I just need to get this one thing fixed.
(Idk if it had anything to do with it but I added a -1 as the default value for the show_menu since a default value was missing.)
And, yes, the default value can be anything you want.
-IMP
I freaking love you this has been annoying me to tears lately! XD Finally! Thank you so much!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











