JavaScript questions that don't deserve their own thread

Discussion in 'Javascript/Plugin Support' started by Shaz, Oct 23, 2015.

  1. DreamX

    DreamX Veteran Veteran

    Messages:
    816
    Likes Received:
    812
    First Language:
    English
    use .x instead of ._x
     
    Milena likes this.
  2. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A


    It works, but it somehow takes the x and y from the editor, I think?


    Because I want the sprite I showed on the map to be in the exact location with the event's x and y.


    My event is at 4, 3 and the sprite only shows on top. It should be on the same position as the event.
     
    Last edited by a moderator: Sep 9, 2016
  3. DreamX

    DreamX Veteran Veteran

    Messages:
    816
    Likes Received:
    812
    First Language:
    English
    Code:
    // change to event id you're looking for
    var eventId = 1;
    
    var event = $gameMap.events().filter(function(event) { return event.eventId() === eventId; } )[0];
    var x = event.x;
    var y = event.y;
     
  4. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A


    It does work. The x and y is detected. But say for example, my sprite is at 4, 16 on the editor. When I detect the x and y using this code, it shows me 4 and 16 as well. So when I update the picture's x and y, it also goes to 4 and 16, instead of where the event sprite is being placed on the screen. Is there a solution so the image should follow the event instead? The game player has a screenX and screenY where you can use it to make an image follow the player, but I don't know for events.
     
    Last edited by a moderator: Sep 9, 2016
  5. DreamX

    DreamX Veteran Veteran

    Messages:
    816
    Likes Received:
    812
    First Language:
    English
    Oh sorry, I missed that you wanted the screen x and y.


    To get the screen x and y try


    screenX()


    and


    screenY()

    Code:
    // change to event id you're looking for
    var eventId = 1;
    
    var event = $gameMap.events().filter(function(event) { return event.eventId() === eventId; } )[0];
    var screenX = event.screenX();
    var screenY = event.screenY();
     
    Last edited by a moderator: Sep 9, 2016
    Milena likes this.
  6. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    Ah, thanks, it works properly now :) I never thought there's one too for events. I missed that out. Thanks!
     
    DreamX likes this.
  7. sundricat

    sundricat Veteran Veteran

    Messages:
    35
    Likes Received:
    2
    First Language:
    English
    What do I need to do to get the following calculation to work?


    ($gameTroop.members()[1]._mmp / $gameTroop.members()[1]._mp) * 100
     
  8. sundricat

    sundricat Veteran Veteran

    Messages:
    35
    Likes Received:
    2
    First Language:
    English
    Never mind. My problem was coming from trying to do the calculation on a nonexistent enemy in the troop I was testing, as I forgot that was zero-based.
     
  9. sundricat

    sundricat Veteran Veteran

    Messages:
    35
    Likes Received:
    2
    First Language:
    English
    I know I could just use the event command, but how would I control a variable using a script call with a condition, in the same script call, for controlling the variable.


    I need to do many variable calculations in a short amount of time, and script calls are very quick.
     
    Last edited by a moderator: Sep 9, 2016
  10. SergeX

    SergeX Veteran Veteran

    Messages:
    64
    Likes Received:
    14
    First Language:
    Portuguese
    Hi. I wonder if anyone could help me.


    In my game, I want a character to have a passive ability like the Thornmail effect presented by Yanfly, but with some changes. 


    I would like to tie the recoil damage within a variable, so depending of the value of the variable, the recoil could range from 0 to a +50% boost and also  a -50% deboost.


    Also, I would like to add a check, so the recoil effect only activates with contact physical damage. It would be very strange seeing a long range attack like a bow being punished by the recoil. Maybe a piece of code to put on long ranged skills that surpass and negate the recoil damage? I'm clueless in how to make this kind of thing, though. The code for the Thornmail effect is below. Thanks in advance!

    Code:
    [SIZE=10px]<Custom React Effect>
    // Check to see if any physical damage is dealt.
    if (value > 0 && this.isPhysical()) {
      // Sets the Recoil Rate to 15%.
      var rate = 0.15;
      // Determines the amount of recoil damage dealt.
      var recoil = value * rate;
      // Sets the DEF bonus rate to 25%.
      var rate = 0.25;
      // Determines the amount of bonus damage dealt.
      var bonus = target.def * rate;
      // Rounds up the bonus damage and recoil damage.
      var dmg = Math.ceil(bonus + recoil);
      // Makes the attacker lose damage equal to the dmg variable.
      user.gainHp(-1 * dmg);
      // Check to see if the attacker is dead.
      if (user.isDead()) {
        // If the attacker is dead, make it collapse.
        user.performCollapse();
      }
    }
    </Custom React Effect>[/SIZE]
     
    Last edited by a moderator: Sep 11, 2016
  11. The_D

    The_D Dr Member

    Messages:
    11
    Likes Received:
    2
    Location:
    US
    First Language:
    English
    I was wondering if this would be a good place to ask about an RPG Maker MV Plugin tutorial. I tried a couple on YouTube, and looked around for some other ones, but I'm not having much luck. I already finished a JS tutorial on CodeAcademy, but I would like to understand the RPGM system much better.
     
  12. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A


    Which ones did you try? Driftwood Gaming featured some channels that do MV Plugin tutorials. This channel is by far the most updated one.
     
  13. The_D

    The_D Dr Member

    Messages:
    11
    Likes Received:
    2
    Location:
    US
    First Language:
    English


    That's one of the two I tried. I got stuck on #14 the other was by SumRndmDude, but someone suggested trying a non-video tutorial. I think I might just go back and try the Soulpour one again.
     
  14. Resonance

    Resonance Veteran Veteran

    Messages:
    43
    Likes Received:
    6
    First Language:
    English
    I'd like to add my own parameters, but I don't know if I should add them ontop of the existing parameter array, or if I should create a new one.


    Does anyone happen to know off the top of their head if any default scripts perform loops on actor parameters under the assumption it's always the standard length?
     
  15. sundricat

    sundricat Veteran Veteran

    Messages:
    35
    Likes Received:
    2
    First Language:
    English
    How would I check to see if a certain scene is loaded?
     
  16. forteller

    forteller Veteran Veteran

    Messages:
    105
    Likes Received:
    17
    First Language:
    English
    How do i get the party leaders level and or the average level among all party members
     
  17. erikmidnatt

    erikmidnatt Mercenary Wizard possessed by an Evil Spirit Veteran

    Messages:
    361
    Likes Received:
    89
    Location:
    Enrich Castle
    First Language:
    English
    Primarily Uses:
    RMMV
    So I've done some digging and can't find an answer in the help file or around the forums. I'm trying to check if the control variable 1, has a value of 1 or more. I'm using YED Skill shop which allows for custom requirements to learn a skill via notetags. The example given used actor level, which works  great.


    actor.level > 10


    So I just need the equivalent snippet for checking control variable 1 (or is it 0001). Any help would be appreciated. I'm sure this is super simple.
     
  18. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    743
    Likes Received:
    539
    First Language:
    English
    Primarily Uses:
    RMMV
    That should just be as follows :

    Code:
    $gameVariables.value(1) >= 1;
     
    erikmidnatt likes this.
  19. erikmidnatt

    erikmidnatt Mercenary Wizard possessed by an Evil Spirit Veteran

    Messages:
    361
    Likes Received:
    89
    Location:
    Enrich Castle
    First Language:
    English
    Primarily Uses:
    RMMV
    thank you so much. I happened to find another posters code example(earlier in this thread). Very much appreciated.
     
    Last edited by a moderator: Oct 11, 2016
  20. Rutibex

    Rutibex Villager Member

    Messages:
    26
    Likes Received:
    16
    Hello, I am trying to make Yanflys Main Menu Manager disable a menu command with a switch.  How can I make it do that?  It says it is an "eval" what ever that means.  I assume it want a piece of code that says "GameSwitch23 = True" or something but I don't know how to format it exactly.


    Please help!
     
    Last edited by a moderator: Oct 13, 2016

Share This Page