Toggle plugin on/off with control switch

Discussion in 'Javascript/Plugin Support' started by vampyyri, Mar 5, 2016.

  1. Shaz

    Shaz Veteran Veteran

    Messages:
    37,552
    Likes Received:
    11,260
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Alright - you've got something weird happening here. What exactly is this._encounterMeter?  Look at what you're doing with it:

    Code:
    this._encounterMeter = $gameSwitches.value(20);
    ...
    this._encounterMeter.refresh(gauge_value, gauge_max);    //Line 49
    ...
    this._encounterMeter = new Encounter_Meter(gauge_value, gauge_max);
    By putting this._encounterMeter = $gameSwitches.value(20) you are setting the value of _encounterMeter to true or false, you are not setting the visibility of an Encounter_Meter type of object.  So get rid of that line from there, then go into the Encounter_Meter.prototype.refresh function, and add this:


    this.visible = $gameSwitches(20);


    I'm not actually sure if that's the correct syntax - could be this._visible or something else.  I don't have the MV scripts open in front of me.
     
    #21
  2. vampyyri

    vampyyri Villager Member

    Messages:
    15
    Likes Received:
    0
    First Language:
    English


    Ok I put it at the beginning and end with .visible, ._visible, and .visibility and it's still drawn to the screen. Of course the error goes away when removing that line. The switch is set in MV at game start to be disabled, so I don't see an issue there.
     
    #22
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,552
    Likes Received:
    11,260
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    beginning and end of what?  You don't need it in both places - only once.  Maybe refresh is not being called on every frame.  Is there an update function?  If there is, put it in there.  If there isn't, find the Scene_Map.prototype.update function and add:


    this._encounterMeter.visible = $gameSwitches(20);
     
    #23
  4. vampyyri

    vampyyri Villager Member

    Messages:
    15
    Likes Received:
    0
    First Language:
    English
    That worked!


    this._encounterMeter.visible = $gameSwitches.value(20);


    Hmm for some reason the encounter happens on my empty test project, but not here. Nothing happens when the gauge is full. And it is counting steps in areas where the gauge isn't visible. I know at least that it works in the test project I had....
     
    #24
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,552
    Likes Received:
    11,260
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Different problem.  I suggest you either have a very close look at what's different between your test project and "here" (wherever "here" is), and if you can't figure it out, make a post in Yanfly's plugin thread.
     
    #25

Share This Page