ID:261533
 
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?
Eagle Madigan wrote:
what did I do wrong?

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
In response to Lummox JR (#1)
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

In response to Eagle Madigan (#2)
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.
mob
var/strength

Harry Potter.dm:4:error:m.defense/2:undefined var
You'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
In response to Lummox JR (#3)
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?)

In response to Eagle Madigan (#4)
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
In response to Lummox JR (#5)
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.

In response to Eagle Madigan (#6)
Eagle Madigan wrote:
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

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:
mob
verb
Attack(...)
var/DAMAGE = ...

Your indentation may look correct, but it's not.

Lummox JR
In response to Lummox JR (#7)
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
In response to Eagle Madigan (#8)
Eagle Madigan wrote:
Now what?:

Now the line with the if() is indented too far. It should be at the same indentation level as the line before it.

Lummox JR
In response to Lummox JR (#9)
PERFECT!!!!!!! thank you