JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 118 of 171 View original ↗
  1. depends on the plugin, the window, as most uses the default font,
    you probably need 2 lines added to that window:

    this.contents.fontFace = "YOURFONTNAME" //this.standardFontFace();
    this.contents.fontSize = 26; // size of the font

    the this.standardFontFace() is the gameFont, but you also want to reset it,
    or add the function inside that window.

    Window_NAME.prototype.resetFontSettings = function() {
    this.contents.fontFace = "YOURFONTNAME"
    this.contents.fontSize = 26;
    this.resetTextColor();
    };

    so you can use a different font.
    keep in mind that this is a hardcoded way, so it is not changeable easely
    unless you make it do so.
  2. AquaEcho said:
    This is at least the third time you asked for help with a plugin without saying what the plugin actually is.
    I was talking in general I'm trying to learn javascript to see if I can write my own
  3. Two questions:
    1a. How do I check if an area a x b tiles extending out from the player, with the player tile in the top left has another event in it?

    1b. How do I check if any of the tiles in that area are say, region Id 4?

    2. How do I do a tint overlay over the player or an event?

    I turned my player character into a tent a x b tiles in area and need to check if there is any other event or impassable water tiles in the way. Also I want to tint the tent red if it's unplaceable
  4. Hi I'm trying to use these 2 scripts but they don't work:

    JavaScript:
    $gameParty.members(1).isStateAffected(252);
    
    $gameParty.members()[1].addState(258);

    The first checks that the member of party 1 has a certain state, while the second serves to give it the state. Unfortunately neither works ... :kaoswt2:
    Where did I go wrong?
  5. AquaEcho said:
    Two questions:
    1a. How do I check if an area a x b tiles extending out from the player, with the player tile in the top left has another event in it?
    You just use a for loop to look at each coordinate, making sure you don't go off the map.
    Code:
    for (let x=1; x<=a; x++)
    {
        for (let y=1; y<=b; y++)
        {
            if ($gamePlayer.x+x>=$gameMap.width() || $gamePlayer.y+y>=$gameMap.height())
                continue;
            if ($gameMap.eventsXy(x, y).length>0)
                return true;
        }
    }
    return false;

    And you set the values for (or put this in a function and pass in) a and b.

    AquaEcho said:
    1b. How do I check if any of the tiles in that area are say, region Id 4?
    Where I have the eventsXy() call, you do $gameMap.regionId(x, y)==4

    Super015 said:
    Hi I'm trying to use these 2 scripts but they don't work:

    JavaScript:
    $gameParty.members(1).isStateAffected(252);
    This is incorrect syntax. You even use the correct syntax in your second line, but for some reason you're doing it differently here. It should be $gameParty.members()[1]

    Super015 said:
    $gameParty.members()[1].addState(258);[/CODE] [/QUOTE] This code is correct. If it's not working, then you should: - Make sure you're referencing the correct actor. The first member of your party (the leader) is 0, not 1 - Look at where you're calling this code and see if there's an error in that. You should probably start your own thread in plugin support if you have more questions.
  6. Ok, I figured out the cause of the problem, I had placed the script in plugin command...

    picard-facepalm.jpg
  7. How are treated if statements and labels in the MZ compiler? Is it skipping a bunch of them directly to the right destination? Or does it still check every line until meeting the right condition.
  8. Narch said:
    How are treated if statements and labels in the MZ compiler? Is it skipping a bunch of them directly to the right destination? Or does it still check every line until meeting the right condition.
    JavaScript is not a compiled language.

    And it depends entirely how you write the code - that's the point of "else if," to make the expression not be evaluated if a prior one was true.

    If you just write rows of "if" "if" "if" then of course the engine will evaluate each one, that's what you've told it to do.

    A label is something different, I'm not sure what you're asking there.
  9. ATT_Turan said:
    JavaScript is not a compiled language.

    And it depends entirely how you write the code - that's the point of "else if," to make the expression not be evaluated if a prior one was true.

    If you just write rows of "if" "if" "if" then of course the engine will evaluate each one, that's what you've told it to do.

    A label is something different, I'm not sure what you're asking there.

    What I'm not exposing in my question is that I wanted to refactor some code where I have a lot of if statements for performances reason. But, I don't want to specifically use case switches or an array lookup for exemple. So I was wondering if I could just isolate the code snippets in conditional checks, and execute those snippets directly by using labels.
    Something like
    $gameVar result == x go to label "x"

    Would that be a performance benefit (with no real concern on the relative gain compared to If Statements)?
  10. Narch said:
    What I'm not exposing in my question is that I wanted to refactor some code where I have a lot of if statements for performances reason. But, I don't want to specifically use case switches or an array lookup for exemple. So I was wondering if I could just isolate the code snippets in conditional checks, and execute those snippets directly by using labels.
    Something like
    $gameVar result == x go to label "x"

    Would that be a performance benefit (with no real concern on the relative gain compared to If Statements)?
    JavaScript does not have a goto command. The label command is only to reference loops.

    It's hard to tell from your example, as it doesn't show any actual example of code with lots of these if statements you reference. I'd suggest you start a new thread and post actual code, then ask for any suggestions on optimizing it (or whether it needs to be optimized).
  11. ATT_Turan said:
    JavaScript does not have a goto command. The label command is only to reference loops.

    It's hard to tell from your example, as it doesn't show any actual example of code with lots of these if statements you reference. I'd suggest you start a new thread and post actual code, then ask for any suggestions on optimizing it (or whether it needs to be optimized).

    Can you expand more about that label comment? If I follow you correctly, using labels in the code still have the same performance weight because all of the code is still being checked going from A to B, and only serves as a loop going from B to A?
  12. Using visustella battle core, is there something I can add (in the JS: pre damage plugin parameter maybe) to make the minimum damage of all attacks be 1?
  13. DrSyintist said:
    Using visustella battle core, is there something I can add (in the JS: pre damage plugin parameter maybe) to make the minimum damage of all attacks be 1?
    There's no need to use a plugin for this. Just put it in the damage formula for the skill:
    Code:
    Math.max(1, paste your original damage formula here)
  14. This is probably a common question, and perhaps the wrong thread for it, but is there a way to decouple xp from levels?

    That is, I'd like to decide when my characters level up, and have it unrelated to the amount of XP they have. (It feels a small and simple thing, but my googling has come to nought).
  15. Cow_Children said:
    This is probably a common question, and perhaps the wrong thread for it, but is there a way to decouple xp from levels?

    That is, I'd like to decide when my characters level up, and have it unrelated to the amount of XP they have. (It feels a small and simple thing, but my googling has come to nought).
    I would say to just set the EXP reward for all of your enemies to 0, then manually add your level up through an event.

    ScreenShot_20230311174843.png
  16. @AquaEcho I know you are asking for a JS script solution, but I did recently post a tutorial that is very similar to what you are trying to do. It doesn't have the tinting or overlay option, but it does check to see if the Yurt dwelling will fit in the space (not too close to the sides of the map) or if there is an obstacle that will be covered by the dwelling.

    The tutorial can be found using my link below if you want to check it out. It may not be what you are looking for, but I wanted to respond in case it is a helpful option.
  17. ZombieKidzRule said:
    @AquaEcho I know you are asking for a JS script solution, but I did recently post a tutorial that is very similar to what you are trying to do. It doesn't have the tinting or overlay option, but it does check to see if the Yurt dwelling will fit in the space (not too close to the sides of the map) or if there is an obstacle that will be covered by the dwelling.

    The tutorial can be found using my link below if you want to check it out. It may not be what you are looking for, but I wanted to respond in case it is a helpful option.
    I took a look at your tutorial (the video was actually very blurry, edit: it cleared up after reloading). This is actually more complicated my implementation, but yours is a no-plugin solution. Because I use Altimit I just resized collision boundaries on the player when turning them into a tent cursor and on the tent object itself on the map, although Shaz Big Events can also do it for events that don't move. Alternatively if the tent is just a grid of tiles any of the tile changing plugins can rewrite an area, then rewrite it again with blank grass tiles if you want to delete the tent area off the map.
  18. Hey, everyone. New to RPGMaker, and the forum, and using RMMZ for my first project. I have a quick question. I want to use Galv's parallax script to handle graphics for my maps and battles, but I also bought the Visustella plugin library, and I was wondering, does anyone know of any conflicts there? I don't want to get neck deep into my first game only to find out I have to gut it. Thanks in advance!
  19. I have finally got the "if critical hit, add state to target" right, but so far have not been able to do "add TP to user". Here is what I have atm

    Code:
    <JS Post-Damage>
     if(target.result().critical == true)
     {
        user.tp=+15;
     }
    </JS Post-Damage>
    Can anyone correct the user.tp=+15 bit for me?

    Thank you