ID:148191
 
I got this wierd bug where the person's name is added to a list when casting a spell. Here's the code, can anyone help?:
Spell(mob/M)
var/list/choice = list(M)
if(isnull(M.spelllist))
M << "<font color = blue><b>You don't have any spells!"
Battle(M)
else if(M.diseased == 1)
M << "<font color = blue><b>You are too weak to cast spells!"
Battle(M)
else if(M.job == "Swordsman")
var/choose = input("What spell/skill do you want to use?")in list("Power Slash - 50 MP","Rapid Slash - 50 MP","Money Slash - 50 MP","Attack Up - 50 MP","Defense Up - 50 MP")
if(choose == "Power Slash - 50 MP")
if(M.powerslash >> 0)
Power_Slash(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Rapid Slash - 50 MP")
if(M.rapidslash >> 0)
Rapid_Slash(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Money Slash - 50 MP")
if(M.moneyslash >> 0)
Money_Slash(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Attack Up - 50 MP")
if(M.attup >> 0)
Attack_Up(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Defense Up - 50 MP")
if(M.defup >> 0)
Defense_Up(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
else if(M.job == "Spellcaster")
var/choose = input("What spell/skill do you want to use?")in list("Fire - 75 MP","Ice - 75 MP","Thunder - 75 MP","Wind - 75 MP","Earth - 75 MP")
if(choose == "Fire - 75 MP")
if(M.fire >> 0)
Fire(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Ice - 75 MP")
if(M.ice >> 0)
Ice(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Thunder - 75 MP")
if(M.thunder >> 0)
Thunder(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Wind - 75 MP")
if(M.wind >> 0)
Wind(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Earth - 75 MP")
if(M.earth >> 0)
Earth(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
else if(M.job == "Thief")
var/choose = input("What spell/skill do you want to use?")in list("Double Hit - 50 MP","Luck Up - 50 MP","Spark - 60 MP","Agility Up - 50 MP","Steal - 50 MP")
if(choose == "Double Hit - 50 MP")
if(M.doublehit >> 0)
Double_Hit(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Luck Up - 50 MP")
if(M.lukup >> 0)
Luck_Up(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Spark - 60 MP")
if(M.spark >> 0)
Spark(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Agility Up - 50 MP")
if(M.aglup >> 0)
Agility_Up(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Steal - 50 MP")
if(M.steal >> 0)
Steal(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
else if(M.job == "Priest")
var/choose = input("What spell/skill do you want to use?")in list("Heal - 50 MP","Devenom - 50 MP","Holy Bolt - 75 MP","Intelligence Up - 50 MP","Mind Games - 50 MP")
if(choose == "Heal - 50 MP")
if(M.heal >> 0)
Healskill(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Devenom - 50 MP")
if(M.devenom >> 0)
Devenom(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Holy Bolt - 75 MP")
if(M.holybolt >> 0)
Holy_Bolt(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Intelligence Up - 50 MP")
if(M.intup >> 0)
Intelligence_Up(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Mind Games - 50 MP")
if(M.mindgames >> 0)
Mind_Games(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
else if(M.job == "Equaler")
var/choose = input("What spell/skill do you want to use?")in list("Power Slash - 50 MP","Earth - 75 MP","Double Hit - 50 MP","Mind Games - 50 MP","Holy Veil - 150 MP")
if(choose == "Power Slash - 50 MP")
if(M.powerslash >> 0)
Power_Slash(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Earth - 75 MP")
if(M.earth >> 0)
Earth(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Double Hit - 50 MP")
if(M.doublehit >> 0)
Double_Hit(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Mind Games - 50 MP")
if(M.mindgames >> 0)
Mind_Games(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
if(choose == "Holy Veil - 150 MP")
if(M.holyveil >> 0)
Holy_Veil(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)
else if(M.job == "Beginner")
if(M.spelllist.Find("Blaze"))
choice.Add("Blaze - 2 MP")
if(M.spelllist.Find("Heal"))
choice.Add("Heal - 4 MP")
if(M.spelllist.Find("Firebal"))
choice.Add("Firebal - 4 MP")
if(M.spelllist.Find("Icebolt"))
choice.Add("Icebolt - 6 MP")
if(M.spelllist.Find("Bolt"))
choice.Add("Bolt - 8 MP")
if(M.spelllist.Find("Sleep"))
choice.Add("Sleep - 5 MP")
if(M.spelllist.Find("Boltmore"))
choice.Add("Boltmore - 12 MP")
if(M.spelllist.Find("Blazemore"))
choice.Add("Blazemore - 14 MP")
if(M.spelllist.Find("Firebane"))
choice.Add("Firebane - 18 MP")
if(M.spelllist.Find("Snowstorm"))
choice.Add("Snowstorm - 22 MP")
if(M.spelllist.Find("Healmore"))
choice.Add("Healmore - 10 MP")
if(M.spelllist.Find("Boltmost"))
choice.Add("Boltmost - 28 MP")
if(M.spelllist.Find("Blazemost"))
choice.Add("Blazemost - 30 MP")
if(M.spelllist.Find("Firebolt"))
choice.Add("Firebolt - 36 MP")
if(M.spelllist.Find("Sleepmore"))
choice.Add("Sleepmore - 12 MP")
if(M.spelllist.Find("Blizzard"))
choice.Add("Blizzard - 44 MP")
if(M.spelllist.Find("Healmost"))
choice.Add("Healmost - 22 MP")
if(M.spelllist.Find("Zap"))
choice.Add("Zap - 48 MP")
if(M.spelllist.Find("Extreme Blaze"))
choice.Add("Extreme Blaze - 58 MP")
if(M.spelllist.Find("Firevolt"))
choice.Add("Firevolt - 64 MP")
if(M.spelllist.Find("Sleepmost"))
choice.Add("Sleepmost - 18 MP")
if(M.spelllist.Find("Blizmore"))
choice.Add("Blizmore - 70 MP")
if(M.spelllist.Find("Healall"))
choice.Add("Healall - 30 MP")
if(M.spelllist.Find("Zapmore"))
choice.Add("Zapmore - 74 MP")
if(M.spelllist.Find("Extreme Blazemore"))
choice.Add("Extreme Blazemore - 78 MP")
if(M.spelllist.Find("Fireroar"))
choice.Add("Fireroar - 86 MP")
if(M.spelllist.Find("Blizmost"))
choice.Add("Blizmost - 90 MP")
if(M.spelllist.Find("Zapmost"))
choice.Add("Zapmost - 96 MP")
if(M.spelllist.Find("Extreme Blazemost"))
choice.Add("Extreme Blazemost - 102 MP")
if(M.spelllist.Find("Firesoar"))
choice.Add("Firesoar - 106 MP")
if(M.spelllist.Find("Master Blizzard"))
choice.Add("Master Blizzard - 112 MP")
if(M.spelllist.Find("Thordain"))
choice.Add("Thordain - 120 MP")
if(M.spelllist.Find("Death Blaze"))
choice.Add("Death Blaze - 132 MP")
if(M.spelllist.Find("Firerage"))
choice.Add("Firerage - 150 MP")
if(M.spelllist.Find("Death Icebolt"))
choice.Add("Death Icebolt - 166 MP")
if(M.spelllist.Find("Thordainmore"))
choice.Add("Thordainmore - 174 MP")
if(M.spelllist.Find("Death Blazemore"))
choice.Add("Death Blazemore - 186 MP")
if(M.spelllist.Find("Fireplow"))
choice.Add("Fireplow - 200 MP")
if(M.spelllist.Find("Death Snowstorm"))
choice.Add("Death Snowstorm - 208 MP")
if(M.spelllist.Find("Thordainmost"))
choice.Add("Thordainmost - 220 MP")
if(M.spelllist.Find("Death Blazemost"))
choice.Add("Death Blazemost - 232 MP")
if(M.spelllist.Find("Firestreak"))
choice.Add("Firestreak - 250 MP")
if(M.spelllist.Find("Death Blizzard"))
choice.Add("Death Blizzard - 264 MP")
choice += "Cancel"
choice.Remove(M.name)
var/choose = input("What spell do you wish to cast?","Spells") in choice
if(choose == "Blaze - 2 MP")
Blaze(M)
if(choose == "Heal - 4 MP")
Heal(M)
if(choose == "Firebal - 4 MP")
Firebal(M)
if(choose == "Icebolt - 6 MP")
Icebolt(M)
if(choose == "Bolt - 8 MP")
Bolt(M)
if(choose == "Sleep - 5 MP")
Sleep(M)
if(choose == "Boltmore - 12 MP")
Boltmore(M)
if(choose == "Blazemore - 14 MP")
Blazemore(M)
if(choose == "Firebane - 18 MP")
Firebane(M)
if(choose == "Snowstorm - 22 MP")
Snowstorm(M)
if(choose == "Healmore - 10 MP")
Healmore(M)
if(choose == "Boltmost - 28 MP")
Boltmost(M)
if(choose == "Blazemost - 30 MP")
Blazemost(M)
if(choose == "Firebolt - 36 MP")
Firebolt(M)
if(choose == "Sleepmore - 12 MP")
Sleepmore(M)
if(choose == "Blizzard - 44 MP")
Blizzard(M)
if(choose == "Healmost - 22 MP")
Healmost(M)
if(choose == "Zap - 48 MP")
Zap(M)
if(choose == "Extreme Blaze - 58 MP")
Extreme_Blaze(M)
if(choose == "Firevolt - 64 MP")
Firevolt(M)
if(choose == "Sleepmost - 18 MP")
Sleepmost(M)
if(choose == "Blizmore - 70 MP")
Blizmore(M)
if(choose == "Healall - 30 MP")
Healall(M)
if(choose == "Zapmore - 74 MP")
Zapmore(M)
if(choose == "Extreme Blazemore - 78 MP")
Extreme_Blazemore(M)
if(choose == "Fireroar - 86 MP")
Fireroar(M)
if(choose == "Blizmost - 90 MP")
Blizmost(M)
if(choose == "Zapmost - 96 MP")
Zapmost(M)
if(choose == "Extreme Blazemost - 102 MP")
Extreme_Blazemost(M)
if(choose == "Firesoar - 106 MP")
Firesoar(M)
if(choose == "Master Blizzard - 112 MP")
Master_Blizzard(M)
if(choose == "Thordain - 120 MP")
Thordain(M)
if(choose == "Death Blaze - 132 MP")
Death_Blaze(M)
if(choose == "Firerage - 150 MP")
Firerage(M)
if(choose == "Death Icebolt - 166 MP")
Death_Icebolt(M)
if(choose == "Thordainmore - 174 MP")
Thordainmore(M)
if(choose == "Death Blazemore - 186 MP")
Death_Blazemore(M)
if(choose == "Fireplow - 200 MP")
Fireplow(M)
if(choose == "Death Snowstorm- 208 MP")
Death_Snowstorm(M)
if(choose == "Thordainmost - 220 MP")
Thordainmost(M)
if(choose == "Death Blazemost - 232 MP")
Death_Blazemost(M)
if(choose == "Firestreak - 250 MP")
Firestreak(M)
if(choose == "Death Blizzard- 264 MP")
Death_Blizzard(M)
if(choose == "Cancel")
Battle(M)


Anyone please help!
Metroid wrote:
I got this wierd bug where the person's name is added to a list when casting a spell. Here's the code, can anyone help?:

Spell(mob/M)
var/list/choice = list(M)

Lummox JR
In response to Lummox JR
I changed it to

var/list/choice = list(M.spelllist)

which is the right thing and now it has /list instead of the person's name.
In response to Metroid
Nope. What you want is var/list/choice = M.spelllist.Copy(). What you were doing there is making a list with a list inside it.
In response to DarkView
Well, the problem is, I have the spells and stuff already there. Like the code sees if its in spelllist, and if its there, it gives the choice and the MP i need to cast it, when I do it the way u showed me, I have two lists of my spells, one that doesn't tell how much MP you need(cause it copied the spell from the spelllist) and one that does cause it found it and renamed it. If I take out the line, it wont work because there is nothing to do this:
if(M.spelllist.Find("Blaze"))
choice.Add("Blaze - 2 MP")
if(M.spelllist.Find("Heal"))
choice.Add("Heal - 4 MP")
if(M.spelllist.Find("Firebal"))
choice.Add("Firebal - 4 MP")
if(M.spelllist.Find("Icebolt"))
choice.Add("Icebolt - 6 MP")
if(M.spelllist.Find("Bolt"))
choice.Add("Bolt - 8 MP")
if(M.spelllist.Find("Sleep"))
choice.Add("Sleep - 5 MP")
if(M.spelllist.Find("Boltmore"))
choice.Add("Boltmore - 12 MP")
if(M.spelllist.Find("Blazemore"))
choice.Add("Blazemore - 14 MP")
if(M.spelllist.Find("Firebane"))
choice.Add("Firebane - 18 MP")
if(M.spelllist.Find("Snowstorm"))
choice.Add("Snowstorm - 22 MP")
if(M.spelllist.Find("Healmore"))
choice.Add("Healmore - 10 MP")
if(M.spelllist.Find("Boltmost"))
choice.Add("Boltmost - 28 MP")
if(M.spelllist.Find("Blazemost"))
choice.Add("Blazemost - 30 MP")
if(M.spelllist.Find("Firebolt"))
choice.Add("Firebolt - 36 MP")
if(M.spelllist.Find("Sleepmore"))
choice.Add("Sleepmore - 12 MP")
if(M.spelllist.Find("Blizzard"))
choice.Add("Blizzard - 44 MP")
if(M.spelllist.Find("Healmost"))
choice.Add("Healmost - 22 MP")
if(M.spelllist.Find("Zap"))
choice.Add("Zap - 48 MP")
if(M.spelllist.Find("Extreme Blaze"))
choice.Add("Extreme Blaze - 58 MP")
if(M.spelllist.Find("Firevolt"))
choice.Add("Firevolt - 64 MP")
if(M.spelllist.Find("Sleepmost"))
choice.Add("Sleepmost - 18 MP")
if(M.spelllist.Find("Blizmore"))
choice.Add("Blizmore - 70 MP")
if(M.spelllist.Find("Healall"))
choice.Add("Healall - 30 MP")
if(M.spelllist.Find("Zapmore"))
choice.Add("Zapmore - 74 MP")
if(M.spelllist.Find("Extreme Blazemore"))
choice.Add("Extreme Blazemore - 78 MP")
if(M.spelllist.Find("Fireroar"))
choice.Add("Fireroar - 86 MP")
if(M.spelllist.Find("Blizmost"))
choice.Add("Blizmost - 90 MP")
if(M.spelllist.Find("Zapmost"))
choice.Add("Zapmost - 96 MP")
if(M.spelllist.Find("Extreme Blazemost"))
choice.Add("Extreme Blazemost - 102 MP")
if(M.spelllist.Find("Firesoar"))
choice.Add("Firesoar - 106 MP")
if(M.spelllist.Find("Master Blizzard"))
choice.Add("Master Blizzard - 112 MP")
if(M.spelllist.Find("Thordain"))
choice.Add("Thordain - 120 MP")
if(M.spelllist.Find("Death Blaze"))
choice.Add("Death Blaze - 132 MP")
if(M.spelllist.Find("Firerage"))
choice.Add("Firerage - 150 MP")
if(M.spelllist.Find("Death Icebolt"))
choice.Add("Death Icebolt - 166 MP")
if(M.spelllist.Find("Thordainmore"))
choice.Add("Thordainmore - 174 MP")
if(M.spelllist.Find("Death Blazemore"))
choice.Add("Death Blazemore - 186 MP")
if(M.spelllist.Find("Fireplow"))
choice.Add("Fireplow - 200 MP")
if(M.spelllist.Find("Death Snowstorm"))
choice.Add("Death Snowstorm - 208 MP")
if(M.spelllist.Find("Thordainmost"))
choice.Add("Thordainmost - 220 MP")
if(M.spelllist.Find("Death Blazemost"))
choice.Add("Death Blazemost - 232 MP")
if(M.spelllist.Find("Firestreak"))
choice.Add("Firestreak - 250 MP")
if(M.spelllist.Find("Death Blizzard"))
choice.Add("Death Blizzard - 264 MP")


How can I fix this?
In response to Metroid
Spell(mob/M)
var/choice[0]
.
.
.


... should work. It looks like you just need a blank list to add to.
In response to Flick
Thanks, it works.