Healing Potion(SOLVED)

1234676543224
22 Feb 2021, 22:35

I am very new to quest and working on my first game, which is a fighting RPG. I am having a problem with a healing potion that would heal the player 30 hit points. I created a shop for magical items using the tutorial ("Setting up a shop"). My problem is, whenever I buy a healing potion from the shop, and drink it, the potion does not disappear (so it has unlimited uses). I created a verb, "drink", and the script I currently have for it is this:
msg ("You drink the potion.") player.hitpoints = player.hitpoints + 30 RemoveObject (healing potion1)
When I drink the potion in the game, it removes the healing potion from the shop's inventory, not the player's.
Another minor problem with it is that you can eat the potion when you have not yet bought it. What I want it to do is to remove the clone of the potion from the player's inventory. Healing potions are fundamental for fighting RPGs. Please post a solution if you have one!
Thank you!


jmnevil54
22 Feb 2021, 23:29

Is the potion a created object or a cloned object?


mrangel
23 Feb 2021, 08:57
if (Contains (game.pov, this)) {
  player.hitpoints = player.hitpoints + 30
  msg ("You drink the potion.")
  RemoveObject (this)
}
else {
  msg ("That isn't yours.")
}

1234676543224
23 Feb 2021, 18:27

Thx so much, my problems is solved.