ID:1095822
 
(See the best response by DarkCampainger.)
Code:
mob/var/cards = 0

mob/proc/CardCheck()
if(src.cards >= 11)
usr << "You feel parchment starting to unfold in your pocket."
var/obj/Scrolls/Write/S = new(usr)
S.Text = "You must find the first of many. Whether you use your mind or not does matter. Perhaps you've seen me watching you as you turn mice and birds right into batter!"

obj/Godric_Gryffindor
icon = 'cards.dmi'
icon_state = "godric"
verb/Take()
set src in oview(1)
for(var/obj/Godric_Gryffindor/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Godric Gryffindor was the Co-Founder of Hogwarts School of Witchcraft and Wizardry. He is the origin of Gryffindor house.")

obj/Uric_the_Oddball
icon = 'cards.dmi'
icon_state = "Uric"
verb/Take()
set src in oview(1)
for(var/obj/Uric_the_Oddball/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Uric the Oddball is well know for his outrageous transfigurations and socially awkward behavior. Many people consider him the weirdest wizard to exist in wizard history. Another thing he's well known for is wearing a jellyfish hat.")

obj/Dobby_the_Free
icon = 'cards.dmi'
icon_state = "Dobby"
verb/Take()
set src in oview(1)
for(var/obj/Dobby_the_Free/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Dobby was a unique house elf in history. He was one of the few who did not want a master, and eventually earned his freedom when Harry Potter hid a sock in a diary and tricked his master into handing the diary to him. Many believe that he was under the influence of Hermione Granger's S.P.E.W.'s movement, but this happened 2 years before the S.P.E.W. came around.")

obj/Bertie_Bott
icon = 'cards.dmi'
icon_state = "bott"
verb/Take()
set src in oview(1)
for(var/obj/Bertie_Bott/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Bertie Bott is the inventor of Bertie Bott's Every Flavored Beans. He's not known for much else.")

obj/Herpo_the_Foul
icon = 'cards.dmi'
icon_state = "herpo"
verb/Take()
set src in oview(1)
for(var/obj/Herpo_the_Foul/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Herpo the Foul practiced dark magic. He was the first to hatch a great serpent Basilisk, and invented many curses. He's also one of the first people to use a horcrux.")

obj/Albus_Dumbledore
icon = 'cards.dmi'
icon_state = "dumbledore"
verb/Take()
set src in oview(1)
for(var/obj/Albus_Dumbledore/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Albus Dumbledore started off as a professor in Transfiguration. Many years later, he served as the Headmaster at Hogwarts. Due to his studious personality, he mastered many arts in the wizarding world. Because of this, he is considered the most powerful wizard of his time.")

obj/Yen_the_Alchemist
icon = 'cards.dmi'
icon_state = "Yen"
verb/Take()
set src in oview(1)
for(var/obj/Yen_the_Alchemist/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Yen was a powerful Chinese alchemist who was around over a thousand years ago.")

obj/Amelia_the_Lonely
icon = 'cards.dmi'
icon_state = "Amelia"
verb/Take()
set src in oview(1)
for(var/obj/Amelia_the_Lonely/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Amelia is famous for being the only witch to befriend a wisp. She commited suicide after being insulted by one.")

obj/Alberic_the_Stinky
icon = 'cards.dmi'
icon_state = "Alberic"
verb/Take()
set src in oview(1)
for(var/obj/Alberic_the_Stinky/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Alberic Grunnion was born in 1803. He was accidentally the inventor of the dungbomb, which was made in an attempt to actually serve as an invisibility potion.")

obj/Harry_Potter
icon = 'cards.dmi'
icon_state = "Potter"
verb/Take()
set src in oview(1)
for(var/obj/Harry_Potter/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Harry Potter was the only wizard to have survived the killing curse. He attended Hogwarts School of Witchcraft and Wizardry and is responsible for the demise of the Dark Lord.")


obj/Merlin
icon = 'cards.dmi'
icon_state = "merlin"
verb/Take()
set src in oview(1)
for(var/obj/Merlin/G in usr)
usr << "You already have [G]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse("Merlin was a great wizard from the Middle Ages. No one today knows much about his past, except for the fact that he served in King Arthur's court. He was the most powerful wizard of his time.")


Problem description:
I don't know if it's something in this file or something else, but ever since I added this code, the game won't load. It just shows you the server and client window.
That has nothing to do with such a problem, or doesn't seem so.
I'd suggest you to revert the latest changes, or use a backup file. Since you could've touched something wherever in your codefiles, and that might be a problem to encounter.

Did you replace world/New() without calling it's parent?
That could be a problem.
Turned out to be a random issue that fixed itself. I guess I request the deletion/lock of this thread.
Unless you want to drive yourself totally insane, you really should write generic verbs:

 obj

verb/Take()
set src in oview(1)
for(var/obj/O in usr.contents)
if(O.type == src.type)
usr << "You already have [src]."
return 0
src.loc = usr
usr.cards += 1
usr.CardCheck()
verb/Read_Card()
set src in usr
usr << browse(desc)


Now none of your cards have to include this code:

obj
Godric_Gryffindor
icon = 'cards.dmi'
icon_state = "godric"
desc = "Godric Gryffindor was the Co-Founder of Hogwarts School of Witchcraft and Wizardry. He is the origin of Gryffindor house."

Uric_the_Oddball
icon = 'cards.dmi'
icon_state = "Uric"
desc = "Uric the Oddball is well know for his outrageous transfigurations and socially awkward behavior. Many people consider him the weirdest wizard to exist in wizard history. Another thing he's well known for is wearing a jellyfish hat."

Dobby_the_Free
icon = 'cards.dmi'
icon_state = "Dobby"
desc = "Dobby was a unique house elf in history. He was one of the few who did not want a master, and eventually earned his freedom when Harry Potter hid a sock in a diary and tricked his master into handing the diary to him. Many believe that he was under the influence of Hermione Granger's S.P.E.W.'s movement, but this happened 2 years before the S.P.E.W. came around."

Bertie_Bott
icon = 'cards.dmi'
icon_state = "bott"
desc = "Bertie Bott is the inventor of Bertie Bott's Every Flavored Beans. He's not known for much else."

Herpo_the_Foul
icon = 'cards.dmi'
icon_state = "herpo"
desc = "Herpo the Foul practiced dark magic. He was the first to hatch a great serpent Basilisk, and invented many curses. He's also one of the first people to use a horcrux."

Albus_Dumbledore
icon = 'cards.dmi'
icon_state = "dumbledore"
desc = "Albus Dumbledore started off as a professor in Transfiguration. Many years later, he served as the Headmaster at Hogwarts. Due to his studious personality, he mastered many arts in the wizarding world. Because of this, he is considered the most powerful wizard of his time."

Yen_the_Alchemist
icon = 'cards.dmi'
icon_state = "Yen"
desc = "Yen was a powerful Chinese alchemist who was around over a thousand years ago."

Amelia_the_Lonely
icon = 'cards.dmi'
icon_state = "Amelia"
desc = "Amelia is famous for being the only witch to befriend a wisp. She commited suicide after being insulted by one."

Alberic_the_Stinky
icon = 'cards.dmi'
icon_state = "Alberic"
desc = "Alberic Grunnion was born in 1803. He was accidentally the inventor of the dungbomb, which was made in an attempt to actually serve as an invisibility potion."

Harry_Potter
icon = 'cards.dmi'
icon_state = "Potter"
desc = "Harry Potter was the only wizard to have survived the killing curse. He attended Hogwarts School of Witchcraft and Wizardry and is responsible for the demise of the Dark Lord."

Merlin
icon = 'cards.dmi'
icon_state = "merlin"
desc = "Merlin was a great wizard from the Middle Ages. No one today knows much about his past, except for the fact that he served in King Arthur's court. He was the most powerful wizard of his time."



As a side note, I was trying to use a variable in the for loop to make it more concise:

var/mytype = src.type
for(mytype in usr.contents)
return 0


but that doesn't work at all :P Maybe someone else knows a way to do it like that?
In response to Magicsofa
Best response
Magicsofa wrote:
As a side note, I was trying to use a variable in the for loop to make it more concise:

> var/mytype = src.type
> for(mytype in usr.contents)
> return 0
>

but that doesn't work at all :P Maybe someone else knows a way to do it like that?

There's no way to dynamically typecast a variable or pass a dynamic type into a for() loop as a type "filter", but this would work in this situation:

if(locate(src.type) in usr.contents)
usr << "You already have [src.name]."
return 0
Ah that makes sense, I forgot about good ol' locate :D Thanks!