JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 131 of 171 View original ↗
  1. Winthorp said:
    I would log the center X and Y in a variable and then log the key pressure of up, down, right, left with an async function on loop.

    Problem is how to avoid RPG Maker to do his standard commands while the plugin is running

    Only way I found (since it's a really low level of the code) is to call a looping auto event in the game flow via switch from the plugin to "freeze" standard user inputs
    I can use a parallel process to check the distance between the player and an event or a position at the center, the challenge is determining which direction's commands to return false, especially if the player is moving diagonally, and implementing that.

    Edit: On second thought, I can probably just use Altimit's built-in event collision boundaries to do this but it's a very plugin-specific solution.
  2. AquaEcho said:
    What's the best way to restrict the player from being able to leave a z radius of a coordinate x,y? I want to tether the player's movement to a range around a coordinate.
    Do you need events to be moving around outside of that radius? The simplest way I can think of is to change the collision map, but that would stop anything from moving outside the radius.
  3. AquaEcho said:
    What's the best way to restrict the player from being able to leave a z radius of a coordinate x,y?
    I would stick it into the movement functions. Game_CharacterBase.isMovementSucceeded() looks like a good place, but you could use Game_CharacterBase.canPass() or anything in the process that you like.

    Have it check for a switch to be on, and if yes it compares the distance from the character's coordinates to coordinates determined by two variables. If >=, the movement fails.

    Then, to use, your event would turn the switch on and save its coordinates into those two variables. You could always include a third variable if you want to be able to control the allowed radius.
  4. Mac15001900 said:
    Do you need events to be moving around outside of that radius? The simplest way I can think of is to change the collision map, but that would stop anything from moving outside the radius.
    Yes, I want to do something similar to FF Crystal Chronicles (although in that game you just take poison damage if you go outside the circle). I'll try modifying some functions in Altimit Pixel Movement, failing that, ATT_Turan's solution is probably the way to go about it.
    ff-crystal-chronicles-remastered-edition-histoire-annee-5-004.jpg
  5. AquaEcho said:
    I'll try modifying some functions in Altimit Pixel Movement
    Ah, that is almost definitely the best way to do it - I'm not particularly familiar with this plugin, but it looks like it probably overwrites a lot of the movement code anyway, so changing the base code might not have actually change what the plugin will do.
  6. Mac15001900 said:
    Ah, that is almost definitely the best way to do it - I'm not particularly familiar with this plugin, but it looks like it probably overwrites a lot of the movement code anyway, so changing the base code might not have actually change what the plugin will do.
    Yes, it's just unfortunate that when it comes to anything Altimit I have to figure it out myself with a lot of trial and error as there are so few people that use it. Right now I have the reverse working: I can keep the player out of a circle boundary created by an event but not keep them in.
  7. Im working on some text for my battle status window but i want it to be in the number font and not the main font. How would i call it in the function? every thing i keep finding in my searches brings up literally changing the overall fonts for the game.

    Window_BattleStatus.prototype.drawTitles = function() { this.drawText('Name', 35, 4); this.drawText('HP', 95, 4); this.drawText('MP', 135, 4); this.drawText(Time', 185, 4); };
  8. Oggy said:
    Im working on some text for my battle status window but i want it to be in the number font and not the main font.
    Code:
    this.contents.fontFace=$gameSystem.numberFontFace();
  9. Hullo, I was wondering if there is a way to access the next index in an array that is 0.

    At the moment, I have to go through every index manually and if it is ==0, do X.
    Example: I have an array with 10 indexes stored in Var1, and I want to store Var2 in the first index that is 0. So I would put:
    1. Conditional branch: $gameVariables.value(1)[0] ==0
    2. If yes: $gameVariables.setValue(1, [0])== $gameVariables.value(2);
    3. If no: Conditional branch: $gameVariables.value(1)[1] ==0
    4. If yes: $gameVariables.setValue(1, [1])== $gameVariables.value(2);
    5. and so on and so forth.

    But it would be a lot easier if I could just put one line that is like:
    Conditional branch: $gameVariables.setValue(1, [index.0])== $gameVariables.value(2);

    I hope this makes sense, does anyone know if this script call exists and what it would look like? If it's more complicated than a simple one liner I can open its own thread. Thanks!
    Lui
  10. stopbeingbored said:
    Hullo, I was wondering if there is a way to access the next index in an array that is 0.

    At the moment, I have to go through every index manually and if it is ==0, do X.
    Example: I have an array with 10 indexes stored in Var1, and I want to store Var2 in the first index that is 0. So I would put:
    1. Conditional branch: $gameVariables.value(1)[0] ==0
    2. If yes: $gameVariables.setValue(1, [0])== $gameVariables.value(2);
    3. If no: Conditional branch: $gameVariables.value(1)[1] ==0
    4. If yes: $gameVariables.setValue(1, [1])== $gameVariables.value(2);
    5. and so on and so forth.

    But it would be a lot easier if I could just put one line that is like:
    Conditional branch: $gameVariables.setValue(1, [index.0])== $gameVariables.value(2);

    I hope this makes sense, does anyone know if this script call exists and what it would look like? If it's more complicated than a simple one liner I can open its own thread. Thanks!
    Lui
    You can loop through an array and exit the loop and return the index of the first 0. Or do you want to overwrite the first 0 with another value? Your question is a little confusing
  11. AquaEcho said:
    You can loop through an array and exit the loop and return the index of the first 0. Or do you want to overwrite the first 0 with another value? Your question is a little confusing
    Thank you, yes I want to replace the first 0 with another value. Sorry for the confusion!
    Also, you referenced "looping" through an array before, do you mean the RMMV loop command or is this a different thing altogether? Thanks
  12. Something like this, I think

    JavaScript:
    for (i = 0; i < $gameVariables.value(1).length; i++) {
    if ($gameVariables.value(1)[i] ==0){
     $gameVariables.value(1)[i] = $gameVariables.value(2);
       break;}
    }
  13. If you want a one line code, does it work like this:

    $gameVariables.value(1)[$gameVariables.value(1).indexOf(0)] = $gameVariables.value(2);
  14. @rpgLord69 Awesome, that worked like a charm!
    @AquaEcho I will try this out as well, I am just starting to wrap my head around for loops.
    Thanks both :)
  15. New question! Is there a script call for labels, which I can amend to include a variable?

    Specifically, instead of jumping to the label named "Label 1", I want to jump to the label called "Label $gameVariables.value(5)".

    This way I can amend Value 5 throughout the event and always jump back and forth to new sections.

    Thanks!
  16. stopbeingbored said:
    Specifically, instead of jumping to the label named "Label 1", I want to jump to the label called "Label $gameVariables.value(5)".
    In a Script command:
    • MV:
      JavaScript:
      this._params = ["Label " + $gameVariables.value(5)];
      this.command119();
    • MZ:
      JavaScript:
      this.command119(["Label " + $gameVariables.value(5)]);
  17. In a Script command:
    caethyril said:
    • MV:
      JavaScript:
      this._params = ["Label " + $gameVariables.value(5)];
      this.command119();
    • MZ:
      JavaScript:
      this.command119(["Label " + $gameVariables.value(5)]);
    Works perfectly. Thank you! :)
  18. rpgLord69 said:
    If you want a one line code, does it work like this:

    $gameVariables.value(1)[$gameVariables.value(1).indexOf(0)] = $gameVariables.value(2);
    @stopbeingbored
    It might be worth pointing out that this will result in some rather strange behaviour if the array does not include this value. If you're certain that it will always be there it's not an issue, but I figured just in case you could use the warning, since troubleshooting this would be quite difficult for a beginner.
  19. Ah, thank you, that is important to note! I will make sure to keep that in mind.

    Mac15001900 said:
    @stopbeingbored
    It might be worth pointing out that this will result in some rather strange behaviour if the array does not include this value. If you're certain that it will always be there it's not an issue, but I figured just in case you could use the warning, since troubleshooting this would be quite difficult for a beginner.