Discuss Scratch

BananaMilkshake1029
Scratcher
19 posts

how to detect if there are multiple of one thing in a list?

im making a crafting system and i need to detect if there are mutiple of one item in the inventory list.
if anyone knows how, please tell me. thanks!
deck26
Scratcher
1000+ posts

how to detect if there are multiple of one thing in a list?

Various methods but if you want duplicate items one option is to store the item name in one list and the corresponding number in another list. You can perhaps fix the item numbers so item A is always item 1 in the list or just add item A to the list as and when you use it.

If you already have the list you can loop through the list and check whether the current item has already appeared either by copyng line by line to a second list or using the item # of thing in list - if that's less than the current item number it must appear earlier in the list.
BananaMilkshake1029
Scratcher
19 posts

how to detect if there are multiple of one thing in a list?

deck26 wrote:

Various methods but if you want duplicate items one option is to store the item name in one list and the corresponding number in another list. You can perhaps fix the item numbers so item A is always item 1 in the list or just add item A to the list as and when you use it.

If you already have the list you can loop through the list and check whether the current item has already appeared either by copyng line by line to a second list or using the item # of thing in list - if that's less than the current item number it must appear earlier in the list.
i don't understand what you mean sorry
deck26
Scratcher
1000+ posts

how to detect if there are multiple of one thing in a list?

BananaMilkshake1029 wrote:

deck26 wrote:

Various methods but if you want duplicate items one option is to store the item name in one list and the corresponding number in another list. You can perhaps fix the item numbers so item A is always item 1 in the list or just add item A to the list as and when you use it.

If you already have the list you can loop through the list and check whether the current item has already appeared either by copyng line by line to a second list or using the item # of thing in list - if that's less than the current item number it must appear earlier in the list.
i don't understand what you mean sorry
What don't you understand? Surely you must understand at least some of it!
BananaMilkshake1029
Scratcher
19 posts

how to detect if there are multiple of one thing in a list?

deck26 wrote:

BananaMilkshake1029 wrote:

deck26 wrote:

Various methods but if you want duplicate items one option is to store the item name in one list and the corresponding number in another list. You can perhaps fix the item numbers so item A is always item 1 in the list or just add item A to the list as and when you use it.

If you already have the list you can loop through the list and check whether the current item has already appeared either by copyng line by line to a second list or using the item # of thing in list - if that's less than the current item number it must appear earlier in the list.
i don't understand what you mean sorry
What don't you understand? Surely you must understand at least some of it!
oooohhh wait i think i understand now. thanks

Powered by DjangoBB