JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 136 of 171 View original ↗
  1. Both MV and MZ have methods specifically for getting/setting a sprite's color tone (cf *_core.js), so you should not need to access the property directly. E.g.
    JavaScript:
    var tone = sprite.getColorTone();
    tone[0] = Math.floor(tone[0] * 0.9);
    sprite.setColorTone(tone);
  2. Ok, I know I have been away for a few months, but I can't figure out why this script is giving a SyntaxError Unexpected Token "{". I am not very good at scripting if else statements.

    if ($gameVariables.value(5).includes($gameVariables.value(6)) || $gameVariables.value(5).includes($gameVariables.value(7)) {
    $gameVariables.setValue(11, 1)
    }

    So, essentially, if the value of Variable 6 or 7 are included in Variable 5 then the value of Variable 11 will be given a value of 1.

    I did this same thing using the Conditional Branch with a Script and it worked fine. Text was displayed depending on the outcome. This is what I used in the Conditional Branch script for the If statement:


    $gameVariables.value(5).includes($gameVariables.value(6)) || ($gameVariables.value(7))

    I want to have a list of values to check to see if they are included in Variable 5. But with the Conditional Branch Script, it is all on one long line and hard to see. So I tried using a Script to make a conditional branch check because you can use many lines which are easier to read.

    I am trying to give Variable 11 a value that I can then check using a regular Conditional Branch to then display text. Because I haven't been able to use a Script to display text so far.
  3. ZombieKidzRule said:
    Ok, I know I have been away for a few months, but I can't figure out why this script is giving a SyntaxError Unexpected Token "{". I am not very good at scripting if else statements.

    if ($gameVariables.value(5).includes($gameVariables.value(6)) || $gameVariables.value(5).includes($gameVariables.value(7)) {
    $gameVariables.setValue(11, 1)
    }

    So, essentially, if the value of Variable 6 or 7 are included in Variable 5 then the value of Variable 11 will be given a value of 1.

    I did this same thing using the Conditional Branch with a Script and it worked fine. Text was displayed depending on the outcome. This is what I used in the Conditional Branch script for the If statement:


    $gameVariables.value(5).includes($gameVariables.value(6)) || ($gameVariables.value(7))

    I want to have a list of values to check to see if they are included in Variable 5. But with the Conditional Branch Script, it is all on one long line and hard to see. So I tried using a Script to make a conditional branch check because you can use many lines which are easier to read.

    I am trying to give Variable 11 a value that I can then check using a regular Conditional Branch to then display text. Because I haven't been able to use a Script to display text so far.
    You were missing a closing parenthesis.

    JavaScript:
    if ($gameVariables.value(5).includes($gameVariables.value(6)) || $gameVariables.value(5).includes($gameVariables.value(7))) {
        $gameVariables.setValue(11, 1);
    }

    If you don't already have it, I'd recommend grabbing VS Code. It's a free code editor that is really good for writing JavaScript. It's a good idea to type your scripts in there, so that simple syntax mistakes will be easier to spot, and then you can copy and paste it into RPG Maker afterward.
  4. @Arthran Thanks for catching that! I thought I only needed 2 at the end instead of 3. Now I can see where all the sets are. And thanks for the suggestion about VS code!
  5. VS code also improve script running in game it corrects automatically and runs faster if you change JS files to VS code
  6. ZombieKidzRule said:
    @Arthran Thanks for catching that! I thought I only needed 2 at the end instead of 3. Now I can see where all the sets are. And thanks for the suggestion about VS code!
    No problem. VS Code would color your parenthesis and braces, so you can tell at a glance which opening one pairs with which closing one. And if you put your cursor on one, it will highlight the other. It'll also give you a warning if there are any missing.

    mantaslukocius said:
    VS code also improve script running in game it corrects automatically and runs faster if you change JS files to VS code
    It's just a text editor, so it doesn't make your scripts run faster or anything like that. But it has some features that can help you type of read code more easily, so it's a good tool to have.
  7. hello, im looking for a way to remove a state and change it for another once the fist state gets to 50 turns

    im working with Buffs & States Core (YEP)

    i try using this in the notes of the state but didnt work:

    <Custom Apply Effect> if (user.actorId() == 1) { if ($gameActors.actor(1)._stateTurns[14] >= 50) { $gameTemp.reserveCommonEvent(7); } </Custom Apply Effect> <Reapply Add Turns>

    where CommonEvent(7) only removes the first state and add the new state to actor 1.

    thanks for your time :)
  8. SnakeBD said:
    where CommonEvent(7) only removes the first state and add the new state to actor 1.
    does it have to make use of the common event? you could do it just by this if it doesnt
    Code:
    <Custom Apply Effect>
    if (user.actorId() == 1 && user._stateTurns[14] >= 50){
      user.removeState(stateId);
      user.addState("second state Id");
    }
    </Custom Apply Effect>
  9. SnakeBD said:
    hello, im looking for a way to remove a state and change it for another once the fist state gets to 50 turns
    Well, you have a syntax error because you have two open braces but only one close. (the inner conditional doesn't need one at all)

    There's also not really a reason to use a common event for this, just do user.addState(X)
  10. How can I edit skill description and also use (always, never, in battle etc) in MV?

    Also I can't post any new thread, is that normal?
  11. Indinera said:
    Also I can't post any new thread, is that normal?
    not usually, no

    Indinera said:
    How can I edit skill description
    $dataSkills[x].description

    Indinera said:
    also use (always, never, in battle etc
    $dataSkills[x].occasion
    0,1,2,3 is always, battle, menu, and never respectively
  12. Thank you.
  13. But it won't save those changes (at least if you shut down and restart the game), right?
  14. rpgLord69 said:
    But it won't save those changes (at least if you shut down and restart the game), right?
    thats a good point i never considered. it does in fact, not save after a restart
  15. Indinera said:
    How can I edit skill description and also use (always, never, in battle etc) in MV?
    This is the same in MV and MZ - all aspects of a skill are stored in the database and cannot be properly edited (with the changes saved) during play.

    You'd either change which skill the actor has to something that's similar but with those differences; or you'd need someone to make a plugin that creates a new data object for skills that reads the values from the database and then gets included in the save file, similar to Yanfly's Independent Items for items.

    rpgLord69 said:
    But it won't save those changes (at least if you shut down and restart the game), right?
    And, perhaps a niche situation but even more confusing, if the player were to quit and start a new game without closing the game, those changes would still be present at the beginning.
  16. ATT_Turan said:
    And, perhaps a niche situation but even more confusing, if the player were to quit and start a new game without closing the game, those changes would still be present at the beginning.
    Hardly niche at all. This is something that can happen even if dev playtesting that'll cause confusion if you forget you added a script call in xD
  17. So I'm using this RMMV Blackjack Plugin: https://github.com/teh-grza/RMMV-blackjack

    I spoke with the dev a long while back and he was planning on implementing what I'm wanting to do, but he's all but abandoned the plugin I don't know how long ago.

    What I want to do is either:

    1) Remove the black background (make the background transparent?) so I can just use my own "Show Picture"/"Erase Picture" calls before or after the Plugin Command

    OR

    2) Just change the black background in the Scene itself into the image I want to use.

    But I don't know how to do either of those things. Can anyone help with whichever one is easiest?
  18. On @Indinera 's issue:

    Actually, if it simply needs to display a specific label AFTER reading an existing value on any other part of the DB, then a plugin could help here. This might change depending on what kind of value that is because it might not be the same value for all actors.

    What the plugin should do is simple, it simply finds a wildcard and replaces it with the actual value in question here.
  19. Torqus said:
    Hey everyone. In VX Ace, with help from the forum, I made a new window to remove actors from party with a list. The problem now is that the new RM doesn't come with a "script" editor. Am I supposed to go to the "js" folder and edit the base scripts there? It seems a lot harder than before, all the scenes, windows are together in 1 file now.
    It's things like this that make me wonder if I'm better off the way I am now with just having MV.
  20. SpyroFan67 said:
    It's things like this that make me wonder if I'm better off the way I am now with just having MV.
    The "problem" that person is describing applies to MV too. Though personally I consider being allowed to use our own code editors to be a good thing, rather than a problem.