ID:142283
 
Code:
mob
verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
oview() << "[usr] attacks [M]!" //send this message to everybody else
var/damage = rand(1,10) //assign a random # to a new variable
world << "[damage] damage!" //tell the damage to the world
M.hp -= damage
var
hp = 100
str = 2
def = 2
damage = 0
src = 1


Problem description:

Its Says Verbs.dm:30:error:M.hp:undefined var

I have no idea what to do...when i ad M.HP as a var it says duplicate meaning with the original HP... Please Help!



Assuming that what you posted is exactly right, your problem is that there is no mob/hp variable, all the variables you declared were global. Just make the variables for the mob.
You don't have to define the damage var twice, delete it from the:

mob
var
damage = 0


And just have it as:

            var/damage = rand(1,10)
In response to Hi1
Hi1 wrote:
> mob
> var
> damage = 0
>


First off i fail to see where he has mob/var anywhere that would be why hp comes back as an error its not defined.
In response to A.T.H.K
A.T.H.K wrote:
First off i fail to see where he has mob/var anywhere that would be why hp comes back as an error its not defined.

This is his:
Jackadelic wrote:
Code:
mob
> verb
> attack(mob/M as mob in oview(1))
> usr << "You attack [M]!"
> oview() << "[usr] attacks [M]!"
> var/damage = rand(1,10)
> world << "[damage] damage!"
> M.hp -= damage
>
var
> hp = 100
> str = 2
> def = 2
> damage = 0
> src = 1


He has the mob/var stacked:
mob
verb
//Verb Stuff
var
//Var Stuff
In response to Hi1
Since he used 2 different code boxes, that would imply the code is in 2 different places. Neither is there any indentation posted before "var".
Besides, gee - tell you what - if he did have it like that, he wouldn't get his error.
In response to Kaioken
He could, because in the

mob
var
damage = 0


It is stating that the damage is 0, but with the other it is stating that the damage will be random, 1 - 10. So DM could get confused......
In response to Hi1
Except, the only error is about the HP var, not damage.
Not to mention having an object variable with the same name as a local variable is perfectly legal. They're accessed in a different manner, therefore Dream Maker can differentiate between them. Of course, his implementation of both of them is unneeded, but it will not cause an error - only the programmer would possibly be confused by this, not the compiler.
In response to Kaioken
o.o .....you is smart =P
In response to Hi1
Hi1 wrote:
you is smart

are*
Sorry, couldn't help it. =P
In response to Kaioken
lol, I know what I wrote! I was proving a point that you ARE smarter than me, lol