[solved]I'm doing a heal on lvl up plugin

● ARCHIVED · READ-ONLY
Started by rokimoki 8 posts View original ↗
  1. Hi, I have this code: [embedded media]

    The thing is, I found this: Excel sheet pinned in forums.

    And what I want is, to heal HP and MP on level up to all actors, and I have some plugin params to heal that ammount specified by the configuration, so.... At the moment it should heal all the HP because I'm forcing to heal maxHP amount, but it doesn't heal.

    So... I need a bit of orientation and how to access to a plugin param (I guess is the name given to the param, but my name params are not a single name).

    Thanks in advance...
  2. The problem is that: $gameActors.length is undefined, so I'm making an alternative....
  3. $gameActors.length doesn't work because $gameActors is an object that has a list of all actors defined in the database.
    To get the length of the list of all actors you need to do $dataActors.length.
    But I don't understand why you want to loop over all actors, when 1 actor leveled up. So do you want to heal HP and MP for all actors, when 1 actor leveled up?

    Also to access a plugin parameter you do:
    Code:
    var parameters = PluginManager.parameters('HealOnLvUp');
    var hpValue = parameters['Value of HP'];
  4. Hello, and thanks for the reply.

    You are right, why am I healing all members? I can't answer, just feeling stupid. Anyway, so I have to reference the actor who just leveled up.

    $dataActors.length return 3, and I just have 2 actors. Anyway, I wanted to know if the actor is in the party, because I get the other actor late in the game. (but not neccesary, just curiosity)

    The param system I just read in other scripts, but I found something like:

    Code:
        var pluginParams = pluginParams || {}; // this????
    
        var parameters = PluginManager.parameters('HealOnLvUp');
    
        pluginParams.percentageHP = parseInt(parameters['% of HP']);
        pluginParams.percenttageMP = parseInt(parameters['% of MP']);
        pluginParams.valueHP = parseInt(parameters['Value of HP']);
        pluginParams.valueMP = parseInt(parameters['Value of MP']);
        pluginParams.mode = parseInt(parameters['Mode']);
      
        function howManyActors () { // this is what I did to know how many actors, works
            var i = 1;
            while ($gameActors.actor(i) != null) i++;
            return i - 1;
        }

    Thanks ^^
  5. $dataActors returns 3 because it is an array. Arrays start at index 0, but the database starts at index 0. So in every $dataXXX list is one emtpy entry at index 0. So you just do $dataActors.length - 1, to get the actual length.
  6. waynee95 said:
    $dataActors returns 3 because it is an array. Arrays start at index 0, but the database starts at index 0. So in every $dataXXX list is one emtpy entry at index 0. So you just do $dataActors.length - 1, to get the actual length.

    But in my Actors.json I can see the ID, and with $gameActors.actor(0) return null, so... I have to do from 1 to < $dataActors.length, as far I know...

    Anyway, this is my updated script:


    And this._mhp gets undefined
  7. fixed: getter parameter used without underscore: this.mhp
  8. Yeah I was just talking about the length in general. If you want to loop over the actors, you would have to start at 1 and go until < $dataActors.length, yes.