JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 157 of 171 View original ↗
  1. Robro33 said:
    the right idea, but a couple mistakes
    members() is a function that doesnt have parameters and gives you an array of members. then, the individual members have a currentClass() function, but its a function and needs the (), and the id for the class youd get from that is id, not Id

    You, sir, are a lifesaver! Thank you very much!
  2. Robro33 said:
    skills and items can be given effects to permanently increase a parameter by some amount. the editor calls the effect "grow"
    If it's permanent, I think I need that as well. How to get that per an actor's stat?
  3. i forgot theres a change parameter event command, but its mechanically the same as the grow effect
    Fionn23 said:
    How to get that per an actor's stat?
    if you dont use it, you dont need to handle it. but if you do, once you have a valid reference to an actor, its actor._paramPlus[parameterId]
    You cannot use the function of the same name for this because itll add in gear
  4. Upon building my code, it seems like I do need to get the gear's stat increase/decrease of an actor. How do I get that?
  5. Fionn23 said:
    Upon building my code, it seems like I do need to get the gear's stat increase/decrease of an actor. How do I get that?
    then you use actor.paramPlus(parameterId) as i mentioned and it should just be the stats from gear and parameter changes/grow effects
  6. Fionn23 said:
    Upon building my code, it seems like I do need to get the gear's stat increase/decrease of an actor. How do I get that?
    Just to point it out, these are all listed and described in detail in the pinned script call list.

    1731125593543.png
  7. Hello! I'm trying to get an array of the first four skills of each battle member, and put the array in a game variable. The below throws an undefined, however, and naturally the game variables remain 0... would appreciate any pointers.
    JavaScript:
    $gameParty.battleMembers().forEach(function(m) {
        $gameVariables.setValue(m.index()+45, m._skills.slice(0,4));
        });
  8. werzaque said:
    The below throws an undefined, however, and naturally the game variables remain 0... would appreciate any pointers.
    its unclear whats actually happening here. by all means, that should be working.
    this wouldnt return anything, so if you put it in a the console and were expecting output it would be undefined, but the setting of variables 45 and onwards should have happened

    when have you tried this, and is battleMembers() actually providing battlers at that time?
  9. Robro33 said:
    when have you tried this, and is battleMembers() actually providing battlers at that time?
    Thanks. I tried it in a battle test, got nothing, so typed it directly into the console, and the variables stayed zero. But if it should work, I’ll try again tomorrow, so thanks for the confirmation! Thought that maybe the fact that splice creates a new array instead of modifying the existing one might have something to do with it in a way I wasn’t understanding…
  10. werzaque said:
    Thought that maybe the fact that splice creates a new array instead of modifying the existing one might have something to do with it in a way I wasn’t understanding…
    nah. in this instance, there wouldnt be any functional difference using slice and splice other than altering the original ._skills array.

    whenever you do return to it, do make sure that battleMembers() is actually providing battlers and then maybe try your code in a clean project. I wouldnt think any plugin would make changes that would render that function to not do anything in battle, but theres a certain set of popular plugins for MZ that i dont use and cannot read, so :shrug:

    1731247189311.png
    - my main MV project
  11. werzaque said:
    Thanks. I tried it in a battle test, got nothing, so typed it directly into the console, and the variables stayed zero. But if it should work, I’ll try again tomorrow, so thanks for the confirmation! Thought that maybe the fact that splice creates a new array instead of modifying the existing one might have something to do with it in a way I wasn’t understanding…
    Small thing - if you have less than 45 variables allocated in your game variables, it will not assign a value to it since your index will be starting at 45. Change the maximum to be 50 and it should work.

    The script call does work on my project when I change it to 50. Changed it back to 20 and it does not "exist" yet, so nothing gets assigned.

    Edit:
    If you were looking to put everything in one variable only, you could go the object route:
    JavaScript:
    const obj = {};
    for (const a of $gameParty.battleMembers()) obj[a.index()] = a._skills.slice(0, 4);
    $gameVariables.setValue(1, obj);
  12. Also, _skills is only for learned skills: it doesn't include skills added by the Add Skill trait.
  13. bass2yang said:
    Small thing - if you have less than 45 variables allocated in your game variables, it will not assign a value to it since your index will be starting at 45. Change the maximum to be 50 and it should work.
    Thanks! I slapped my forehead the moment I read this... so stupid. It was indeed the variables database lacking records. Good to know that it doesn't throw an error even if you reference values that don't exist...

    1731285151979.png
    caethyril said:
    Also, _skills is only for learned skills: it doesn't include skills added by the Add Skill trait.
    Thanks! I did notice this when I looked at _skills and skills(), but since I'm working with Visustella Battle Core, I am currently at the stage of throwing torchlights down the well in the hopes of seeing something. It might actually be a fortunate side effect that the added skills (as well as guard) are treated separately.
  14. How do you check if a skill is a certain hit, physical, or magical?
    edit: it's $dataSkills[skill id].hitType
  15. Braix said:
    How do you check if a skill is a certain hit, physical, or magical?
    edit: it's $dataSkills[skill id].hitType
    I guess you can use these functions (assuming skill = $dataSkills[skill id]):
    skill.isPhysical()
    skill.isMagical()
    skill.isCertainHit()


    Check ATT_Turan's and Robro33's replies below for the correct answer.

    -x-

    I have a question too:
    Is there a way to check if user.currentAction() is targeting a specific actor, considering that that action targets an opponent?
  16. TheNewSon said:
    I guess you can use these functions (assuming skill = $dataSkills[skill id]):
    That's not correct. The $dataSkills array is the database entries for the skills. That doesn't have any methods, only properties storing the values entered for the skills - as Braix showed in their own post.

    Those functions are all methods of the Game_Action type.

    TheNewSon said:
    I have a question too:
    Is there a way to check if user.currentAction() is targeting a specific actor, considering that that action targets an opponent?
    Have you not been recommended the MV library by now? It's very easy to look up questions like this:

    Clicking into the Game_Actor class and going to the currentAction() method, it returns a Game_Action object:
    1731340441733.png

    Clicking into Game_Action, one of its properties is _targetIndex

    1731340481535.png

    So you'd just check whether the _targetIndex in the game party has a specific actor ID.

    But, of course, that's completely without context - if you're accessing this via some plugin that gives you user it's hard to imagine it doesn't also simply provide target
  17. TheNewSon said:
    I guess you can use these functions (assuming skill = $dataSkills[skill id]):
    i depends on how youre checking. those 3 methods are for Game_Action and are easily accessable when using most plugins that deal with customizing action effects, but using $dataSkills gets you the type independent of the action.

    TheNewSon said:
    Is there a way to check if user.currentAction() is targeting a specific actor, considering that that action targets an opponent?
    depends on where youre using this.
    if its in a yanfly notetag for example, most already have a target variable available but <Custom Action Start Effect>s cant actually access the target by then. you can grab the ._targetIndex out of the action and use it on the user's opponent's unit, but iirc enemies do just fire them off at random with -2 (or -1. cant remember and the difference is not important right now)
  18. @ATT_Turan
    I've just bookmarked it for future references, thanks!

    @Robro33
    Ohhh so that's what I was doing wrong... I was indeed using <Custom Action Start Effect> and the _targetIndex would always return -1. I'm gonna try with <Custom Initiate> now, thanks!
  19. TheNewSon said:
    I'm gonna try with <Custom Initiate> now, thanks!
    And, as mentioned, Initiate provides a target variable.
  20. Is there a way to append a '%' sign to the value of MP gauges? I'm using Visustella plugins.