Variable Not Subtracting in a Function [SOLVED]

For some reason the player's gold is not subtracting when an item is purchased from this Function. Does anyone see what I'm doing wrong?

ClearScreen
menulist = Split("Large Health Potion;Small Health Potion;Decurser;Sewing Kit;Mixing Kit;Metallurgy Kit;Sword of Demonslaying;Leather Whip;Leave", ";")
ShowMenu ("", menulist, true) {
  if (result = "Large Health Potion") {
    msg ("<br/><font color= \"74789D\">\"Hm...4 gold for that.\"</font color><br/><br/>Would you like to buy this?")
    menulist = Split("Yes;No", ";")
    ShowMenu ("", menulist, true) {
      if (result = "Yes") {
        if (player.gold>=4) {
          msg ("<br/>You toss Jensen the gold{random: and then take the item in hand:}. ")
          CloneObjectAndMove (large_health_potion, player)
          player.gold = player.gold - 4
          JensenShop
        }
        else {
          msg ("<br/>You don't have enough.")
          JensenShop
        }
      }
      else if (result = "No") {
        JensenShop
      }
    }
  }
  }

if (player.gold>=4) {  ///no spaces? if (player.gold >= 4) {

There needs to be spaces.

 if (player.gold >= 4) {
}

Also, whenever I have this problem, I need to add space too, or I need to close and reload a game a few times.


I don't think spaces matter. The player is receiving the item just fine which means the script is firing the way it's supposed to but the gold isn't getting subtracted from the script for some reason.

Anonynn.


Okay....so it isn't updating the gold until after I leave the function... e_e


If you mean the gold shown in a status sttribute or similar, that's unfortunately the case now. Status attributes are not updated while a menu is displayed unless you manually call UpdateStatusAttributes.


Yup! I added that in :)


Thanks for your input everyone!

Anonynn


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums