my javascript to deduct gold not working..

Discussion in 'Javascript/Plugin Support' started by bighoncho, May 15, 2019.

  1. bighoncho

    bighoncho Veteran Veteran

    Messages:
    73
    Likes Received:
    46
    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: May 15, 2019
    #1
  2. bighoncho

    bighoncho Veteran Veteran

    Messages:
    73
    Likes Received:
    46
    I have fixed it. pls ignore
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,720
    Likes Received:
    11,430
    Location:
    Australia
    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.
     
    #3

Share This Page