I keep on getting this error:
Harry Potter.dm:4: error: if: expected end of statement
for this code:
mob
verb
Attack(var/mob/M in oview(1))
var/DAMAGE=rand(usr.strength/4 - m.defense/2, usr.strength/2 - m.defense/4) + rand(usr.strength/4 - m.defense/2, usr.strength/2 - m.defense/4) if (DAMAGE > 0) M.HP -= DAMAGE
what did I do wrong?
ID:261533
Jun 13 2002, 8:57 am
|
|
Just makes it worse:
Harry Potter.dm:4:error:usr.strength/4:undefined var Harry Potter.dm:4:error:m.defense/2:undefined var Harry Potter.dm:4:error:usr.strength/2:undefined var Harry Potter.dm:4:error:m.defense/4:undefined var Harry Potter.dm:4:error:usr.strength/4:undefined var Harry Potter.dm:4:error:m.defense/2:undefined var Harry Potter.dm:4:error:usr.strength/2:undefined var Harry Potter.dm:4:error:m.defense/4:undefined var Harry Potter.dm:5:error:DAMAGE:duplicate definition Harry Potter.dm:5:error:0:duplicate definition Harry Potter.dm:5:error:> :instruction not allowed here Harry Potter.dm:5:error::empty type name (indentation error?) Harry Potter.dm:5:error:M.HP:duplicate definition Harry Potter.dm:5:error:DAMAGE:duplicate definition Harry Potter.dm:5:error:-= :instruction not allowed here Harry Potter.dm:5:error::empty type name (indentation error?) this is the code when that is done: mob verb Attack(var/mob/M in oview(1)) var/DAMAGE=rand(usr.strength/4 - m.defense/2, usr.strength/2 - m.defense/4) + rand(usr.strength/4 - m.defense/2, usr.strength/2 - m.defense/4) if(DAMAGE > 0) M.HP -= DAMAGE | |
Eagle Madigan wrote:
Just makes it worse: No. What it's doing is exposing errors that were there already, but weren't showing up because of another error. Harry Potter.dm:4:error:usr.strength/4:undefined var Is there a var/strength line listed for mobs? It's not in the code segment you gave us. If you don't have this var defined, you need to define it.
Harry Potter.dm:4:error:m.defense/2:undefined varYou're looping through var/mob/M, not var/mob/m. The lowercase m is an undefined variable. You should be using uppercase. I think all the other errors hang off those two, but it'll be easier to tell for sure when you've fixed those. Lummox JR | ||
what is wrong now?
mob var/strength mob verb Attack(var/mob/M in oview(1)) var/DAMAGE=rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) + rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) if(DAMAGE > 0) M.HP -= DAMAGE Harry Potter.dm:8:error:usr.strength/4:undefined var Harry Potter.dm:8:error:M.defense/2:undefined var Harry Potter.dm:8:error:usr.strength/2:undefined var Harry Potter.dm:8:error:M.defense/4:undefined var Harry Potter.dm:8:error:usr.strength/4:undefined var Harry Potter.dm:8:error:M.defense/2:undefined var Harry Potter.dm:8:error:usr.strength/2:undefined var Harry Potter.dm:8:error:M.defense/4:undefined var Harry Potter.dm:9:error:DAMAGE:duplicate definition Harry Potter.dm:9:error:0:duplicate definition Harry Potter.dm:9:error:> :instruction not allowed here Harry Potter.dm:9:error::empty type name (indentation error?) Harry Potter.dm:9:error:M.HP:duplicate definition Harry Potter.dm:9:error:DAMAGE:duplicate definition Harry Potter.dm:9:error:-= :instruction not allowed here Harry Potter.dm:9:error::empty type name (indentation error?) | |
Hrm. It occurs to me now that that badly indented var/DAMAGE line wasn't you trying to fit it on the forum, but was in fact you messing up the indentation.
That line, and the one below it, has to be indented beneath the verb definition. By unindenting it all the way over to the left margin, BYOND thinks you've left the verb and you're now defining a global var. Lummox JR | |
Ok here it is now:
mob var/strength mob verb Attack(var/mob/M in oview(1)) var/DAMAGE=rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) + rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) if(DAMAGE > 0) M.HP -= DAMAGE Harry Potter.dm:8: Inconsistent indentation. | |
Eagle Madigan wrote:
Ok here it is now: You've got spaces and tabs mixed for your indentation. This is the one major no-no of BYOND. Use a single tab or a set number of spaces for every indent, like this:
Your indentation may look correct, but it's not. Lummox JR | ||
Now what?:
mob var/HP var/MP var/strength var/defense mob verb Attack(var/mob/M in oview(1)) var/DAMAGE=rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) + rand(usr.strength/4 - M.defense/2, usr.strength/2 - M.defense/4) if(DAMAGE > 0) M.HP -= DAMAGE Harry Potter.dm:14:error:rand:undefined proc Harry Potter.dm:15:error::invalid expression Harry Potter.dm:14:DAMAGE :warning: variable defined but not used | |
Your if() statement needs to go on the next line down; you have it on the same line where var/DAMAGE is assigned. To make that work, you either need to put a semicolon after the end of that assignment, or move if() down a line.
Lummox JR