JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 102 of 171 View original ↗
  1. Wrong spot. Sorry.
  2. Tim_Seraphim said:
    I am randomly getting this bug. It usually happens after an enemy uses a certain skill, but it's not every time an enemy uses that skill.
    Per the first post,
    Shaz said:
    If you need help getting a plugin working, please start a NEW thread and include a link to where you downloaded the plugin from.

    You need to start a new thread in plugin support - but I'll advise you that your error message "the provided value is non-finite" usually happens when you try to put a function into someplace that is expecting a numeric value.

    So when you make that thread, post a screenshot of that skill's damage formula, as that's the most likely place you've put something wrong.
  3. Hello, Is there a way to reference a specific skill being used in a Custom Confirm if statement such as
    if (this.isPhysical() && user._SkillId === 448 && this.isHpEffect() && value !== 0) { ?? Something like that.
  4. this.item().id === 448
  5. Hello,

    I'm trying to set up a conditionnal script that will activate a Switch after several items have been checked from the player inventory. I'm trying to do it all in script to keep clarity as there will be dozen of items to check.

    Any help with that?
  6. @Narch, assuming you are just checking to see if the items are present in the inventory, and you don't care about the number of items and none of them are weapons/armors, you can try the following in a script call:
    Code:
    const hasItem = (itemId) => $gameParty.hasItem($dataItems[itemId]);
    const arrayItems = [1, 2, 3, 4];  // Change item ids in this array
    $gameSwitches.setValue(1, arrayItems.every(hasItem)); // Change switch in this function

    All you need to do is change the numbers within arrayItems to reflect the item ids that you want to check, and the switch value from 1 to the actual switch that you want to change.

    If this is something that you may do multiple times in the game with different items, I would suggest writing a plugin that converts this into a function that accepts an array of item ids.

    P/S: You didn't say which RPG Maker you're using - I tested this with MZ but I think the code should work in MV as well.
  7. When I first started using RPG Maker MV a couple of years ago, I wanted to put an external array in a variable. @Lanzy graciously wrote me a plugin that would do that. Essentially there are 2 lines, no parameters.
    Code:
    var $dataList = null;
    DataManager._databaseFiles.push({name: '$dataList', src: 'List.json'});
    Then all it needs is a simple assignment to a variable
    ◆Control Variables:#0001 arrayFromFile = $dataList

    and a dialogue box will verify the contents
    Contents of variable01 = \v[1]
    shows
    Contents of variable01 = dog,bird,cat,bird,horse

    For reference, here's a link to Lanzy's Code plugin posted earlier in this same thread.

    The plugin works great in MV, but not in MZ. Turning the plugin on in MZ prevents MZ from loading, giving this error (Note, this is a vanilla project, one map, one event, no plugins except Lanzy's.)

    1648076471959.png

    Console shows

    1648076543203.png

    Since I'm using the exact same plugin and .json file from MV, I have to assume MZ either doesn't support this or that the MZ terminology is slightly different.

    tldr: Can someone translate MV's
    Code:
    var $dataList = null;
    DataManager._databaseFiles.push({name: '$dataList', src: 'List.json'});
    to MZ? As always, thank you to any and all who respond.

    As an aside, I was loading the external file within the game itself using
    Code:
    var fs = require('fs');
    :      :var wordList = fs.readFileSync("./data/wordListAbridged.dat", 'utf-8');
    :      :$gameVariables.setValue(1, wordList);
    but, apparently, if I deploy for web, the browser refuses to load the file and this is for a game I made for my grandchildren who use Chrome tablets, not Windows, so I really want to go the .json route if I can.

    Edit-I was able to accomplish loading the word list by copying and pasting the file contents using variable = script, then running that event with autorun when the game starts. Works well enough, seems that the variable had no trouble holding 1700+ words, but I'd still like to know if there's an equivalent of DataManager._databaseFiles for MZ. Thanks again.
  8. (MV) How do I change the y position of text in help windows (like item descriptions, etc.)?

    Edit: Found what I was looking for!
    Code:
    Window_Help.prototype.refresh = function() {
            this.contents.clear();
            this.drawTextEx(this._text, this.textPadding(), 0);
    };
    And then change the 3rd argument in drawTextEx to whatever y-offset you want.
  9. How to wait for animation for actor in battle?

    This is what I have:
    JavaScript:
    let m=$gameParty.members()[r];
    m.startAnimation(161, false, 0);
    let dmg=100*m.elementRate(4);
    // I need a wait for animation here //
    m.gainHp(-dmg);
    m.startDamagePopup();
    if(m.isDead())m.performCollapse();

    btw, this is not a YEP notetag for action sequences, it is a simple script.
  10. stramin said:
    How to wait for animation for actor in battle?
    I believe the last number in the function call (which you're currently setting to 0) is how long to delay game processing for. So if you want to wait for the entire animation, try setting that equal to the number of frames.
  11. Thank you!

    sadly it didn't work, It seems like it works as a delay, if I write 50, it waits for 50 frames and then starts the animation.
  12. stramin said:
    Thank you! sadly it didn't work
    Okay...I looked up where the animations are called in the code, and it looks like the waiting is done through the battle log. So try:
    Code:
    m.startAnimation(161, false, 0);
    BattleManager._logWindow._waitCount=X;
    where X is the number of frames in the animation.
  13. Oh no, this didn't work either, I added a 500 waitCount, it makes the text window to show after some seconds, but the damage popup is not being delayed.

    JavaScript:
    let m=$gameParty.members()[r];
    r=Math.floor(Math.random()*20);
    m.startAnimation(161, false, 1);
    BattleManager._logWindow._waitCount=500; // <- wait
    let dmg=(90+r)*m.elementRate(4);
    m.gainHp(-dmg);
    m.startDamagePopup();// <- this popup shows on the first frame of the animation
    if(m.isDead())m.performCollapse();
  14. I also see stuff for
    Code:
    BattleManager._logWindow.setWaitMode('animation')

    If that doesn't do the trick, someone smarter than me will have to help :stickytongue:
  15. And... it doesn't work xD

    Thank you for your time :kaojoy:
  16. Hello.
    Where do you call this code?
    Code:
    let m=$gameParty.members()[r];
    m.startAnimation(161, false, 0);
    let dmg=100*m.elementRate(4);
    // I need a wait for animation here //
    m.gainHp(-dmg);
    m.startDamagePopup();
    if(m.isDead())m.performCollapse();

    Edit: seems I didn't quote you @stramin, but this was about your issue. You can't stop code in the middle just like that. That's why I asked where do you call this code cause it really depends of the context.
  17. Hi, it is a script event in a troop event page.

    1648835592882.png
  18. Hello @stramin

    If it's in a troop event script command, then it's pretty simple.
    Split your code in 2 parts, one that call the animation and one that does the damage. Then put a regular 'wait' command in between. Of course, you'll have to use a variable to pass the random value to the second code block, but that should do the desired effect.

    Should look like something around that:
    Capture d’écran, le 2022-04-02 à 00.48.49.png

    Regards,
    TSR
  19. Is there a simple way to hide the item command in battle if it is sealed? Would I need a script for that?
  20. FarOutFighter said:
    Is there a simple way to hide the item command in battle if it is sealed? Would I need a script for that?
    You would need a plugin (scripts are for the earlier RPG Makers that use Ruby) such as Victor Engine's Command Replace.