ID:145612
 
Code:
for(var/S in typesof(/obj/items/Magic))
src.item+= S

obj/items
Magic
Bean
Rock
Grass



Problem description: Why is it when I do that it will include "Magic" in the list? Is it supposed to do this? I only wanted to include the items in Magic's string.

try

for(var/S in typesof(/obj/Magic))
src.item+= S

obj
Magic
Bean
Rock
Grass
In response to A.T.H.K
A.T.H.K wrote:
try

> for(var/S in typesof(/obj/Magic))
> src.item+= S
>
> obj
> Magic
> Bean
> Rock
> Grass
>
>
>


That wouldn't and doesn't make a diffrence because it is essiently doing the same exact thing.
Texter wrote:
Code:
for(var/S in typesof(/obj/items/Magic))
> src.item+= S
>
> obj/items
> Magic
> Bean
> Rock
> Grass

Problem description: Why is it when I do that it will include "Magic" in the list? Is it supposed to do this? I only wanted to include the items in Magic's string.


Try adding a "/" to the end of Magic in the first line.
It's because you're not filtering /obj/Magic from the list. You can try typesof(/obj/Magic/), but it may not work. Your best bet is to use for(var/M in typesof(/obj/Magic/)-/obj/Magic)
if(istype(S,/obj/Magic)) continue
In response to Artemio
Artemio wrote:
if(istype(S,/obj/Magic)) continue

Uh, no. istype() returns true if it is derived from any of the type's child paths. You would want to compare it to an exact path type. What CaptFalcon wrote is a correct way to do it.

~~> Unknown Person