ID:172359
 
i get this annoying runtime error when i try out my magic system.

runtime error: Cannot read "Fire".Stype
proc name: Spellcast (/proc/Spellcast)
usr: Redslash (/mob/Person)
src: null
call stack:
Spellcast(Redslash (/mob/Person), Bear (/mob/Monster/Bear), "Fire")
spells(Redslash (/mob/Person), Bear (/mob/Monster/Bear))
Pattack(Redslash (/mob/Person), Bear (/mob/Monster/Bear))
encounter(Redslash (/mob/Person), Bear (/mob/Monster/Bear))
Attack grass (5,2,1) (/turf/Attack_grass): Entered(Redslash (/mob/Person), Attack grass (4,2,1) (/turf/Attack_grass))

i think its caused by the way i add the magic to the list
proc newspells(mob/P) if(P.Class=="Person" && P.lvl==2) if(!P.spells) P.spells = new P.spells+="Fire" P<<"You Learned Fire!" P.spellknown=1
if i change that code, then when i try to look at P.spells in a stat panel or call it in input, it messes up, anyone know why?
I call it with this code, which is bad and messy...
proc spells(mob/P, mob/E) if(P.spellknown>=1) var/spell=input("Which spell do you want to cast?") in P.spells call(/proc/Spellcast)(P,E,spell) else call(/proc/Pattack)(P,E) Spellcast(mob/P, mob/E, obj/spell) if(spell.Stype=="Hurt") if(P.MP>=spell.MP) var/damage=rand(P.DarkSkill*spell.damagelow,P.DarkSkill*spel l.damagehigh) E.HP-=damage P.Dark_exp+=1 call(/proc/Darklvlupcheck)(P) call(/proc/deathcheckMON)(P,E) else P<<"Not enough MP!" call(/proc/Pattack)(P,E) if(spell.Stype=="Heal") if(P.MP>=spell.MP) var/heal=rand(P.LightSkill*spell.heallow,P.LightSkill*spell. healhigh) P.HP+=heal P.Light_exp+=1 call(/proc/Lightlvlupcheck)(P) call(/proc/Eattack)(P,E) else P<<"Not enough MP!" call(/proc/Pattack)(P,E)
I also made sure P was the usr and E was the enemy.
Redslash wrote:
runtime error: Cannot read "Fire".Stype
proc name: Spellcast (/proc/Spellcast)
usr: Redslash (/mob/Person)
src: null
call stack:

code code code . . .

Spellcast(mob/P, mob/E, obj/spell)
if(spell.Stype=="Hurt")

The error is in the Spellcast proc and it can't read "Fire".Stype

What happend is that obj/spell was defines as a text string ("Fire" in this case) which aint a obj with a Stype var.

Look at the place where the call the proc and make sure you define the obj/spell var as the spell object and not as a (what it seems to me) Stype allready.

Hope it helps, Greetz Fint
In response to Fint
What i was trying to do is a have a text string and put it onto the end of /obj/ so it would make a path, but instead of turning it into /obj/Fire it just turns it into Fire, or "Fire".

However, when i add it into the list by using
proc
newspells(mob/P)
if(P.Class=="Person" && P.lvl==2)
if(!P.spells) P.spells = new
P.spells+=/obj/Fire
P<<"You Learned Fire!"
P.spellknown=1

it gives me this. someone help please
runtime error: Cannot read /obj/Fire (/obj/Fire).Stype
proc name: Spellcast (/proc/Spellcast)
usr: Redslash (/mob/Person)
src: null
call stack:
Spellcast(Redslash (/mob/Person), Bug (/mob/Monster/Bug), /obj/Fire (/obj/Fire))
spells(Redslash (/mob/Person), Bug (/mob/Monster/Bug))
Pattack(Redslash (/mob/Person), Bug (/mob/Monster/Bug))
encounter(Redslash (/mob/Person), Bug (/mob/Monster/Bug))
Attack grass (5,17,1) (/turf/Attack_grass): Entered(Redslash (/mob/Person), Attack grass (5,16,1) (/turf/Attack_grass))
In response to Redslash
Not sure about this but try
P.spells.Add(new /obj/Fire)

Its not that u didnt define the var cuz then u would get a "undefined var" error =P
Your just adding it "wrong", check if you are really adding a object, thats whats going wrong i THINK.

Good Luck!
In response to Fint
LOL thank you so much fint, now that i take a step back to see, i feel like an idiot. you suggestion worked like a working.... thingy. thank you so much.