JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 152 of 171 View original ↗
  1. Hey guys! If I save all of an actor's equipment into a variable (code below) how can I fetch their IDs individually?


    Code:
    $gameVariables.value(1) = $gameActors.actor(1).equips();
  2. @TheNewSon
    1 - you can't do that, you can't assign values to a return value.

    2 - there are a number of threads about how to use arrays in MV's game variables. I suggest you do a Google and read through those.

    3 - once you do have it, you check the individual IDs exactly the same way as when they were in the equips() array of the actor.
  3. @TheNewSon - also you'd typically store the Game_Item data rather than the entire database record, e.g. like the MV / MZ Script Call List examples, Memorise Equipment & Restore Equipment:

    screenshot.png
    Local copy:
    • Memorise:
      JavaScript:
      // Store the party leader's current equipment in variable ID 5
      $gameVariables.setValue(
        5,
        JsonEx.makeDeepCopy($gameParty.members()[0]._equips)
      );
    • Restore:
      JavaScript:
      // Restore the party leader's equipment from variable ID 5
      $gameVariables.value(5).forEach(function(item, slotId) {
        $gameParty.members()[0].forceChangeEquip(
          slotId, item.object()
        );
      });

    Alternatively, to store the IDs of actor ID 1's current equipment, I think you could just use Control Variables -> Script:
    JavaScript:
    Array.from($gameActors.actor(1).equips(), function(item) { return item ? item.id : 0; })
  4. Is there a way to make pictures appears in a higher Z layer than the Battle Log and Actor Battle Gauges? Temporarily, if possible.

    Or to temporarily have pictures appear at the highest Z layer? I'm trying to make an image that appears above the these items in the battle scene.

    I tried to use this plug in here, but I don't know the constructor to allow this: https://forums.rpgmakerweb.com/index.php?threads/changing-picture-z-index-value.155236/
  5. ezgif-5-f0fdf2dcba.gif

    Is there somehow a way to change the animation for when the window pops in and out? I dunno what js file to poke on for this.
  6. ATT_Turan said:
    @Lonewulf123 WindowLayer
    Quick question. Is there a constructor layer that goes higher than this one?

    I was able to get it over the gauges, but it seems like visuatella QTE events appear above even that.

    Wondering if I could get the picture layer even higher.
  7. Animations and the flashing white destination cursor go higher
  8. Lonewulf123 said:
    Quick question. Is there a constructor layer that goes higher than this one?
    I was able to get it over the gauges, but it seems like visuatella QTE events appear above even that.
    I can't tell you anything about VisuStella code. But you might be able to find it, if you open the console and type SceneManager._scene._spriteset.children

    AquaEcho said:
    Animations and the flashing white destination cursor go higher
    Is that a change in MZ? In MV, battle animations display under the windows.
  9. AquaEcho said:
    Animations and the flashing white destination cursor go higher
    Without plugins, that is not correct.

    Lonewulf123 said:
    I was able to get it over the gauges, but it seems like visuatella QTE events appear above even that.
    MZ's core scripts only add 2 display children directly to the map/battle scenes: the spriteset (including animation container and destination sprite), then the window layer (game windows and Touch UI buttons).

    The window layer and the spriteset are siblings; to identify additional layers added by plugins you would check SceneManager._scene.children. This may not help if the QTE sprites are added/removed dynamically.
  10. caethyril said:
    to identify additional layers added by plugins you would check SceneManager._scene.children.
    Bah, I was only off by one! :stickytongue:
  11. Are SceneManager._scene.children sorted using z values?
    If so maybe a high enough z value can solve the problem?
  12. caethyril said:
    Without plugins, that is not correct.


    MZ's core scripts only add 2 display children directly to the map/battle scenes: the spriteset (including animation container and destination sprite), then the window layer (game windows and Touch UI buttons).

    The window layer and the spriteset are siblings; to identify additional layers added by plugins you would check SceneManager._scene.children. This may not help if the QTE sprites are added/removed dynamically.
    Thank you guys, I'll try this.
  13. utunnels said:
    Are SceneManager._scene.children sorted using z values?
    Not as far as I know. The MV/Z tilemaps manually implement z-sorting (Tilemap#_sortChildren), and PIXI.Container has methods like addChildAt for layering.

    [Edit: oh, looks like there may be a sortableChildren flag for auto-sorting. Looks like it's only a shortcut for changing the child order, though.]
  14. caethyril said:
    Without plugins, that is not correct.


    MZ's core scripts only add 2 display children directly to the map/battle scenes: the spriteset (including animation container and destination sprite), then the window layer (game windows and Touch UI buttons).

    The window layer and the spriteset are siblings; to identify additional layers added by plugins you would check SceneManager._scene.children. This may not help if the QTE sprites are added/removed dynamically.
    Coming to report back, I couldn’t find any layers that were added by the QTE. It looks like they were added and removed dynamically like you suggested.

    I could be wrong though, but this how it looks like its handled.

    I’m not sure how to approach this, but I may come up with an alternate solution.
  15. Is there some way to get the current amount of enemies in a fight? I wanted it so that the damage of my multi-target skill is evenly distributed, and I hope there's some thing I could get the values from.
  16. $gameTroop.allMembers().length for what you asked
    $gameTroop.aliveMembers().length for if you meant all alive enemies