ID:178930
 
I'm having a problem creating a list for my spells. The spells exist on the character, but when I run the verb, it skips right over the for loop. Any suggestions?

--------

mob
verb
Cast()
var/O
var/list/spelllist[] = new
for (O in usr.worldspell)
spelllist += O
usr << "create list"
spelllist += "Cancel"
var/spellchoice = input("Which spell do you wish to cast?") in spellchoice
usr << "[spellchoice] choice"
usr << "[usr.worldspell]"
if(spellchoice == "Cancel")
return 0
if(spellchoice == "Heal")
heal()
proc
heal()
var/mpcost = 3
var/healnum = 30 + round(usr.intequip / 5)
var/diffhp = usr.maxhp - usr.hp
if (usr.mp >= mpcost)
if (diffhp == 0)
usr << "You don't need to cast this"
else if (diffhp < healnum)
usr.hp = usr.maxhp
usr << "You were healed for [diffhp] HP."
usr.mp -= mpcost
else
usr.hp += healnum
usr << "You were healed for [healnum] HP."
usr.mp -= mpcost
else
usr << "You do not have enough MP."
There was an error in the code, here is the corrected

------

mob
verb
Cast()
var/O
var/list/spelllist[] = new
for (O in usr.worldspell)
spelllist += O
usr << "create list"
spelllist += "Cancel"
var/spellchoice = input("Which spell do you wish to cast?") in spelllist
usr << "[spellchoice] choice"
usr << "[usr.worldspell]"
if(spellchoice == "Cancel")
return 0
if(spellchoice == "Heal")
heal()
proc
heal()
var/mpcost = 3
var/healnum = 30 + round(usr.intequip / 5)
var/diffhp = usr.maxhp - usr.hp
if (usr.mp >= mpcost)
if (diffhp == 0)
usr << "You don't need to cast this"
else if (diffhp < healnum)
usr.hp = usr.maxhp
usr << "You were healed for [diffhp] HP."
usr.mp -= mpcost
else
usr.hp += healnum
usr << "You were healed for [healnum] HP."
usr.mp -= mpcost
else
usr << "You do not have enough MP."
In response to Rubius
What is usr.worldspell?
In response to Xooxer
usr.worldspell is the user's spell list for the overworld, since I don't want all the spells that they learn to be seen in the overworld. I'm really stuck on this, and any help would greatly be appreciated. If you want to talk about this on messenger, my AIM screen name is rubiuszx2
In response to Rubius
Just to let everyone know, Foomer and I figured the problem out. The list was being seen as a variable because it was a variable. Moral of the story, when declaring lists, make sure you follow it with =new()
In response to Rubius
Why does everyone mistake me for Foomer?