ID:274008
 
var/obj/S = input("Which Sword?","Choose")as null|anything in usr.Swords

It shows anything in swords but how can u make it that if i had 5 swords it would say Swords x5 instead of just Sword
Associative lists.
var/swords_count
for(var/obj/i in Swords)
if(istype(i, /obj/Sword1))
swords_count += 1

var/list/l = list("Sword1 x[swords_count]" = /obj/Sword1)

var/selection = input("Which sword?", "Choose") as null|anything in l

var/obj/S = l[selection]


If an explanation is needed for any of this, just let me know what is confusing you.
In response to Albro1
Albro1 wrote:
Associative lists.
> var/swords_count
> for(var/obj/i in Swords)
> if(istype(i, /obj/Sword1))
> swords_count += 1
>
> var/list/l = list("Sword1 x[swords_count]" = /obj/Sword1)
>
> var/selection = input("Which sword?", "Choose") as null|anything in l
>
> var/obj/S = l[selection]
>

If an explanation is needed for any of this, just let me know what is confusing you.

Why are you using += ?

Just use ++
In response to A.T.H.K
I know about ++, but I tend to use += 1 for faster and easier readability. It's just my preference. Some people may process ++ better than += 1, but I prefer += 1.
In response to A.T.H.K
Seems trivial.
In response to Speedro
If you are referring to me, and just clicked Reply on the wrong post, then I will say it again to save you the trouble of reading my previous post again.

It is user-preference. I program how I am comfortable programming. Up until lately when I started getting into an "organization phase", I used ++. Since then, however, I have been using += for the sake of my own readability.
In response to Albro1
Nope. I replied to the right post.

I think it's trivial whether one uses ++ or +=1.

It is just preference, like you said.
In response to Speedro
Alright then.