Variable Not Subtracting in a Function [SOLVED]

Anonynn
23 Dec 2018, 03:51For 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
}
}
}
}

Forgewright
23 Dec 2018, 04:14if (player.gold>=4) { ///no spaces? if (player.gold >= 4) {
jmnevil54
23 Dec 2018, 04:31There 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.

Anonynn
23 Dec 2018, 05:30I 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.

Anonynn
23 Dec 2018, 07:24Okay....so it isn't updating the gold until after I leave the function... e_e
mrangel
23 Dec 2018, 10:19If 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
.

Anonynn
23 Dec 2018, 18:33Yup! I added that in :)

Anonynn
23 Dec 2018, 18:52Thanks for your input everyone!
Anonynn