JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 94 of 171 View original ↗
  1. LittleMisterFrosty said:
    I tried...
    You should start a new post about this, as it:
    1) clearly deserves its own thread, and
    2) is not actually about using JavaScript, but the functionality of a specific plugin.

    As you do so, try pulling up the console in your game with F8, go to the console, and manually check actors with isStateAffected to try to verify that they in fact don't still have the state on them (as that's what would normally prevent a state from being applied).
  2. WCouillard said:
    I need to alter this so characters never use skill ID 1 or 2 when autobattling
    I also need to alter this so characters always use skills with the skill type ID 2 when autobattling

    Kinda stuck on where to even begin on this one.

    JavaScript:
    Game_Actor.prototype.makeActionList = function() {
        var list = [];
        var action = new Game_Action(this);
        action.setAttack();
        list.push(action);
        this.usableSkills().forEach(function(skill) {
            action = new Game_Action(this);
            if (skill.id !== 1 || skill.id !== 2) {
                action.setSkill(skill.id);
                list.push(action);
           };
        }, this);
        return list;
    };
    
    };
    You only need to worry about this method and while I'm unfamiliar with that particular array method, all you really need to do is fork in a conditional statement that allows all skills to be added to the list that don't have an id of 1 or 2. I modified the code to show you an example of what I mean, but it has not been tested for accuracy.
  3. Could someone help me set up a script call that can set a range of variables to the value of a separate range of variables?

    For a bit of context, I have a range of 20 consecutive variables that contain the id's of the player's deck of trading cards. I want to back up these values into a separate batch of consecutive variables, so I can restore those values at a later time.
  4. i'm trying to make a skill obtained from a weapon, using yanfly skill core, require both a specific state and a variable to be at least one what am i doing wrong?


    <Custom Show Eval>

    if ($gameActors.actor().isStateAffected(22) && $gameVariables.value(1) >==1) {

    visible = true;

    } else {

    visible = false;

    }

    </Custom Show Eval>

    with this the skill shows no matter what
  5. @cubeking1
    try replacing "$gameActors.actor()" with "user"
  6. @Vis_Mage you can use a for loop if they're consecutive. Suppose that your original variables are in variables 100-119, and you want to copy them to variables 200-219. So the code would be:
    Code:
    for (let i = 0; i < 20; i++) {
        let origId = 100 + i;
        let copyId = 200 + i;
        $gameVariables.setValue(copyId, $gameVariables.value(origId));
    }
    You can just change the numbers 100 and 200 to the starting values of your own variables.
  7. ScorchedGround said:
    @cubeking1
    try replacing "$gameActors.actor()" with "user"
    skill still shows no matter what state he is in and the variable is not considered
  8. @cubeking1
    Ah my mistake, the problem is most likely the ">==" then, which should be ">=".

    Try this notetag:

    <Custom Show Eval>
    if (user.isStateAffected(22) && $gameVariables.value(1) >=1) {
    visible = true;
    } else {
    visible = false;
    }
    </Custom Show Eval>
  9. cubeking1 said:
    if ($gameActors.actor().isStateAffected(22) && $gameVariables.value(1) >==1) {
    Just to expand on ScorchedGround's reply, $gameActors.actor() is a function that requires an argument to be passed into it - the ID of the actor you want returned to you. e.g. $gameActors.actor(1)

    And then >== is not a valid operator, but you were already told that.

    If you're learning JavaScript to use in RPG Maker, you may find this a useful reference.
  10. ScorchedGround said:
    @cubeking1
    Ah my mistake, the problem is most likely the ">==" then, which should be ">=".

    Try this notetag:

    <Custom Show Eval>
    if (user.isStateAffected(22) && $gameVariables.value(1) >=1) {
    visible = true;
    } else {
    visible = false;
    }
    </Custom Show Eval>
    this works thank you very much
  11. Edit: I figured it out.
  12. Is there a way to give an actor exp via javascript without the level up message? I know about $gameActors.actor(n).gainExp(x), but if the actor gains enough exp to level up I don't want the message window to pop up.
  13. imaginaryrose said:
    Is there a way to give an actor exp via javascript without the level up message? I know about $gameActors.actor(n).gainExp(x), but if the actor gains enough exp to level up I don't want the message window to pop up.
    Code:
    $gameActors.actors(n).shouldDisplayLevelUp = false

    Can also apply to $gameParty.
  14. Thanks, @Arctica! I couldn't quite get it to work as a script call. It said should shouldDisplayLevelUp is not a function, but then I found the shouldDisplayLevelUp function in rpg_object.js and I figured it out from there. Thanks for the help!
  15. That's because I made a syntax error and only noticed it just now-____-. It should've been actor and not actors.
  16. It's strange, but even with the edit I still couldn't get it to work.
  17. Outside of typos and calling it on objects it doesn't belong to, I can only assume two things that cause that error to be thrown:

    1. It's syntactically different from MZ. It's the only version I use and most of the core files wasn't changed too much if at all.

    2. You missinterpreted my post to be this: $gameActors.actor(n).shouldDisplayLevel() = false

    The bold part will throw the type error, because while it's a method of Game_Actor, it's not to be called as a function in this context.

    In any case, glad you got working.
  18. Shouldn't it be $gameActors.actor(n).shouldDisplayLevel = () => false; instead?
    If shouldDisplayLevel is a function and you overwrite it with false, then eventually something will call false() which will throw an error, because false is not a function.

    Instead, what you want is to overwrite shouldDisplayLevel with a function that returns false, which the arrow function () => false does.
  19. Arctica said:
    2. You missinterpreted my post to be this: $gameActors.actor(n).shouldDisplayLevel() = false

    The bold part will throw the type error, because while it's a method of Game_Actor, it's not to be called as a function in this context.
    You can't just decide something isn't a function. What you typed could be used to store a reference to the shouldDisplayLevel function in a variable and call it later, but it can't change what that function returns.
    Nolonar said:
    Shouldn't it be $gameActors.actor(n).shouldDisplayLevel = () => false; instead?
    That is more like it, if you included that as a plugin - however, my understanding of the original question is that the OP only wanted to not display level ups under specific circumstances.

    So, @imaginaryrose - what do you want to do in your game? If you are always giving exp via script call and never want to display level up information, put Nolonar's line into a plugin.

    But if you also have regular combat, and you want level up info there but not when you're awarding exp outside of combat, you'll need a way to control it. So, again in a plugin,
    Code:
    Game_Actor.prototype.shouldDisplayLevelUp = function() {
        return $gameSwitches.value(X);
    };
    where X is an ID of an unused switch in your game. Then you can use event/script commands to turn that switch on or off and display the level up info accordingly.
  20. That's exactly what I need, @ATT_Turan! Thanks!