ID:179650
 
My healing potion code:

obj/items
Healingpotion
icon = 'items.dmi'
icon_state = "healingpotion"
Click()
if(src in usr)
usr.HP += 100
del(src)

What should i add so my HP doesnt go over my MAXHP ?

THX.
if (usr.HP >= usr.MaxHP)
usr.HP = MaxHP
In response to Bonzi
OK, i've modified it a bit:

obj/items
Healingpotion
icon = 'items.dmi'
icon_state = "healingpotion"
Click()
if(src in usr)
if (usr.hp = usr.maxhp)
usr<<"You don't need it yet!"
return 0
else
usr.hp += 100
if (usr.hp >= usr.maxhp)
usr.hp = usr.maxhp
usr<<"Some HP recovered !"
del(src)

After compiling, it says "missing expression" at
the first "if".
Any ideas ? Should i change something here ?

THX.
In response to Cravens
= isn't a full if expression so try changing it to == or >=
As an alternative to the code you were given, instead of using three lines of code, you can use the convenient min() function:
usr.HP=min(usr.HP+100,usr.maxHP)

That says the user's new HP is either 100 higher than it was, or as high as it can go, whichever comes first.

Lummox JR