JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 67 of 171 View original ↗
  1. You can adjust the size of that event's collision, so that it isn't stopping the player from walking there. QMovement allows you to give events custom collision through comments on the event page. Try this:
    <collider: box, 48,30>
    See if the player is able to get closer to the flower table.
    (You can also use QMap for parallax mapping, as that allows you to create collision for objects without having to use events.)
  2. Sleepy Kitten Games said:
    You can adjust the size of that event's collision, so that it isn't stopping the player from walking there. QMovement allows you to give events custom collision through comments on the event page. Try this:
    <collider: box, 48,30>
    See if the player is able to get closer to the flower table.
    (You can also use QMap for parallax mapping, as that allows you to create collision for objects without having to use events.)

    Thank you so much for the reply! I've been trying to look to how to do comment tags to adjust the size of that event's collision but I'm not sure how to? Is it possible for you to explain to me how to do that?

    **Edit: Found it! Thank you so much! Do you know if it possible for me to be able to make these event 'collisions' passable by the player?
  3. Was the flower table placed in the editor, or with Orange Overlay? If it was placed in the editor then you can do that (because that means it already has collision from the Tilesets tab), but if you placed it with Orange Overlay your best bet is adjusting the collision box so that it matches what the flower table looks like so the player can't walk all over the table.
  4. It's a flat parallax image with an orange overlay image over it so the flowers stick out a bit! I'm using QM+Collision map for the actual collisions (hence the green) the red boxes were indicating the event tiles I put text in (As in the player interacts with the table and says something about roses) Which is why I'm confused why the player can't walk through those boxes the first place.
  5. Ah, I see.
    You can either set the event to be below the player (which has a chance of not working the way you want but you can try it) or you can adjust the collider for that event so that it matches the flower table (which will then make it so the player can interact with that event but its collider won't get in the way of the player).
    The reason the player can't walk through the event box is that an event's collision being set to "same as player" makes it take precedence over the map's collision (be that through the editor, through QMap, or through QM+CollisionMap). It's just like when you create a map in the editor and put an event on that map that's set to "same as player" - the event's collision says that the player cannot walk there.
    That's why my suggestion is to tweak that event's collider so that it lines up with the green area. The player will be able to interact with the event, but the event won't keep the player from walking where you want them able to walk.
  6. Sleepy Kitten Games said:
    The reason the player can't walk through the event box is that an event's collision being set to "same as player" makes it take precedence over the map's collision (be that through the editor, through QMap, or through QM+CollisionMap).
    This part explains the problem I was having thank you so much! I had tweaked the collider earlier when you helped me with the notetag command but I wanted to know what was causing the player being unable to walk through the event collision as I may need to put a collision on an empty tile in the future. I'll definitely look into the in and outs of the events feature because of this.
  7. I'm looking for a script call to return the attributes of an equipped item. For example, if I wanted to find the elemental rate of equipped weapons 1 and 2 on Actor 1.
  8. Accessing traits on data objects is a bit of a pain. You could do something like this though:

    JavaScript:
    var eleId = elementId //replace elementId with actual ID
    var actor = $gameActors.actor(1);
    var weapons = actor.weapons();
    if (weapons[0]) {
        var eleRates = weapons[0].traits.filter(function(trait) {
            return trait.code === 11 && trait.dataId === eleId;  // 11 is trait code for element rate
        }); //filters out any non-relevant traits
    
        var finalRate = eleRates.reduce(function(r, rate) {
            return r * rate.value;
        }, 1) //multiply element rates together in case there are more than one
    } else {
        var finalRate = 1;
    }

    finalRate will contain the element rate of the actors first weapon. If the actor doesn't have a first weapon it will hold a value of 1 (as this is the neutral rate). If you wanted to do this check on the actors second weapon you can replace "weapons[0]" with "weapons[1]".
  9. Is it possible to do a check if the character has changed direction similar to the check $gamePlayer.isMoving(), to be used in a parallel process as a condition.:kaopride: I can't seem to find that via google~

    The other thing I could do is set the direction to a variable and run a check "if x variable has changed", but I haven't learned how to code "if x has changed from the previous variable" without using 2 variables, which may feel a bit messy, but is that my best option? Since it's a parallel process the less processing the better!
  10. Is there a way to, in a script call, search for all events on the map with a specific string in their name? (Context: I'm trying to reset several events' A self switches - the events all have names which have a specific string in them.) I've tried doing a handful of different Google searches, but nothing has seemed to come up.
  11. Riazey said:
    Is it possible to do a check if the character has changed direction similar to the check $gamePlayer.isMoving(), to be used in a parallel process as a condition.:kaopride: I can't seem to find that via google~

    The other thing I could do is set the direction to a variable and run a check "if x variable has changed", but I haven't learned how to code "if x has changed from the previous variable" without using 2 variables, which may feel a bit messy, but is that my best option? Since it's a parallel process the less processing the better!

    Well, maybe this works for you, I didn't test it though D:, without MV where I am exactly now XD, but any issues just tell me.

    Insert it as a new plugin.
    Call this $gamePlayer.changedDirection()
    It will return true if it changed direction, false if it didn't, the moment it returns true it will start to return false (since it will wait to change direction again)
  12. Raizen said:
    Insert it as a new plugin.
    Call this $gamePlayer.changedDirection()
    It will return true if it changed direction, false if it didn't, the moment it returns true it will start to return false (since it will wait to change direction again)

    Thanks for tackling this! :kaohi:There does seem to be an issue~

    1583964954195.png
    1583964966526.png
  13. Sleepy Kitten Games said:
    Is there a way to, in a script call, search for all events on the map with a specific string in their name? (Context: I'm trying to reset several events' A self switches - the events all have names which have a specific string in them.) I've tried doing a handful of different Google searches, but nothing has seemed to come up.

    You could use something like this to filter out the events whose name contain a certain string.
    JavaScript:
    $gameMap.events().filter(function(event) {
        return event.event().name.contains(string); //replace string with string you're searching
    });
    This will return an array containing all the events on the current map that have the string in their name. If you want to toggle the self switches via script as well you could try
    JavaScript:
    var events = $gameMap.events().filter(function(event) {
        return event.event().name.contains(string); //replace string with string you're searching
    });
    var mapId = $gameMap.mapId();
    events.forEach(function(event) {
        var key = [mapId, event.eventId(), 'A'];
        $gameSelfSwitches.setValue(key, true);  //replace true with false if trying to turn switches off
    })
  14. Thanks!
  15. Riazey said:
    Thanks for tackling this! :kaohi:There does seem to be an issue~

    View attachment 136552
    View attachment 136553

    Oops sorry, try this:

    Game_Player.prototype.changedDirection = function() {
    if (this.old_saved_direction == this.direction()){
    return false;
    }
    else{
    this.old_saved_direction = this.direction();
    return true;
    }
    };

    Same thing, just replace it with that, tested here and it seems what you want xD.
  16. Raizen said:
    Oops sorry, try this:

    Game_Player.prototype.changedDirection = function() {
    if (this.old_saved_direction == this.direction()){
    return false;
    }
    else{
    this.old_saved_direction = this.direction();
    return true;
    }
    };

    Same thing, just replace it with that, tested here and it seems what you want xD.

    It works yaaaaay~ Thank-you thank-you!
  17. I'm not sure if i should post this here or in another section on the forum,but i was hoping to figure out how to make the side view battle screen only show one actor or enemy on the screen at a time. Heres a really quick mockup i made:
  18. Hi, not sure if it deserves it own threads, so I post it here, excuse me if I should have started a new post (and if my English is broken too).

    I'm trying to use the Random dialogue plugin Random Dialogue v1.03a. The plugin works fine, but I would like to know if there is a way to do a little bit more and It looks like the creator of the plugin has not been here in a while.

    The plugin command is
    - RandomConversations getRandomMsg category topics faceid -

    I would like to do a condition depending on what appears on the random message, and this condition could affect the player

    I was thinking about something like :

    - Random message possibility for the NPC
    1 Hi, how are you?​
    2 What's your name?
    3 You look pretty smart​

    if plugin call 1 then player could choose something like the answers below.
    Answer 1 Fine -> End​
    Answer 2 fine thanks -> End​
    Answer 3 fine thanks and you? -> call a new message or pv -5 or whatever​

    I think it should be something like
    if random message id [1-3] then pv -5
    or
    if category is vampire then pv - 5

    I've found a hint on the RMMV script call on google docs, below, but not sure how I should use it, so if anyone could help me in any way, it would be a great help

    Code:
    var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
    
    
    
    
    
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
    
    
       aliasPluginCommand.call(this, command, args);
    
    
       if (command === 'plugincommandtextname') {
    
    
          dostuff(args);
    
    
       }
    
    
    };
  19. leusyth said:
    I'm not sure if i should post this here or in another section on the forum,but i was hoping to figure out how to make the side view battle screen only show one actor or enemy on the screen at a time. Heres a really quick mockup i made:
    This will require a custom plugin. I believe creating your thread for that question would be more appropriate since it might require more information and discussion.
  20. Is it possible to retrieve the event ID at specific coordinates position?