my javascript to deduct gold not working..

bighoncho

Veteran
Veteran
Joined
Nov 10, 2016
Messages
76
Reaction score
52
Primarily Uses
Hi,

The code is to check if actor have the 100 gold required, display message if not enough gold
and if enough gold, play a SE and deduct the gold.

If the actor have the gold, it will deduct it. But it will not check for not enough gold and not display message and instead carry on to allow further action even when actor do not have enough gold.. it did not show error message either.

I have also set the correct variables to use which is 7.

$gameVariables.setValue(7,100)
invgold=$gameVariables.value(7);
if($gameParty.gold() < invgold){
$gameMessage.add("Gold is not enough")
this._index = this._list.length
}else{
AudioManager.playSe({"name":"Coin","volume":90,"pitch":100,"pan":0})
$gameParty.loseGold(invgold)
}


Can someone help ?
Thanks!
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,413
Reaction score
12,947
First Language
English
Primarily Uses
RMMV
Wondering why you're doing this in script? It works fine in event commands.

Also not sure why you're setting a variable, retrieving the variable into another, and then using it in the test and command.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Why you do this? Now I have to buy the new RPG Maker xD
I've always dreaded planning for my games so I just didn't plan at all. That... didn't work out after all. :kaosigh:
Turns out it can be kind of fun if you keep the scope small and don't take it way too seriously.
well... for the first time in months... I feel like my game is headed towards something again. I finally have it where I won't be drawing battle assets for the rest of the year...
What I would give to actually get some feedback on my game...

Forum statistics

Threads
99,567
Messages
966,773
Members
131,217
Latest member
sayb
Top