JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 29 of 171 View original ↗
  1. Guys, Yanfly has a support thread for the Yanfly plugins.  Please ask for help with those there rather than here (as per the first post in this thread).
  2. DreamX said:
    If you actually want to change the name you'll need assign the value.



    $gameActors.actor(x)._name = $gameActors.actor(x).name().toUpperCase()

    Oh.
    I did try "$gameActor(x).name =, but I forgot the underscore.

    *EDIT*
    Oh, that's for ALL CAPS.
    Not for a name like "john/JOHN = John."
  3. Is there a way to make scenes to not use the screen resolution when creating windows?
     
  4. Code:
    $gameActors.actor(x)._name = $gameActors.actor(x).name().substr(0,1).toUpperCase() + $gameActors.actor(x).name().substr(1).toLowerCase()



    should work if it's only one name (no spaces).
  5. Shaz said:
    Code:
    $gameActors.actor(x)._name = $gameActors.actor(x).name().substr(0,1).toUpperCase() + $gameActors.actor(x).name().substr(1).toLowerCase()



    should work if it's only one name (no spaces).

    Oh that works perfectly
  6. Where do you exactly determine if one character is dual wield? It's on the battler base, but I want to know where it is set up so I can make one character wield 3 weapons instead of 2?
  7. Milena said:
    Where do you exactly determine if one character is dual wield? It's on the battler base, but I want to know where it is set up so I can make one character wield 3 weapons instead of 2?

    rpg_objects, line 3575, function Game_Actor.equipSlots.
  8. Does anyone know how you would get a picture to fade in, as suppose to just appear?
  9. TheGamedawg said:
    Does anyone know how you would get a picture to fade in, as suppose to just appear?



    You could use the following :

    Code:
    // Show Picture with 0 Opacity
    $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, 0, blendMode);
    
    // Use the movePicture function to fade in the picture; Opacity 255
    $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, 255, blendMode, duration);
  10. Hello quick question I'm suing Yanfly Learn Skill Plug-in, how do I make it so let's say my Item Id 2 allows me to see a skill to learn I belive is with


    <Learn Show Eval>


    value = true;


    value = false;


    </Learn Show Eval>


    But I don't really know.
  11. Hello,


    I've been storing strings in variables via Control Variables->Add->Script, for instance something like this: "\n\C[4]some text here\C[0]". Notice how I am trying to add in the color change escape sequence. After I have set the string up and potentially concatenated it with others (hence the "\n" at the start and the Add operation) I then print it by doing a call to Show Text: "\V[x]". The issue is, the string prints but it does not seem to convert the escaped colors (though oddly enough its interpreting the "\n" correctly). It just prints "C[4]some text hereC[0]" instead, seemingly just stripping off the '\'. I've tried adding a double "\\" but then it just prints "\C[x]". Any ideas on what's going on?


    Here is a basic example of what I'm seeing:


    event logic:

    • Control Variables : #0001 Test Variable = "Test Line 1:"
    • Control Variables : #0001 Test Variable += "\n\C[4]Test Line 2\C[0]"
    • Text : None, Window, Bottom

      : \V[1]


    output:


    "Test Line 1


    C[4]Test Line 2C[0]"


    Any help would be greatly appreciated,


    Thanks!
  12. Ralstafarian said:
    Hello,


    I've been storing strings in variables via Control Variables->Add->Script, for instance something like this: "\n\C[4]some text here\C[0]". Notice how I am trying to add in the color change escape sequence. After I have set the string up and potentially concatenated it with others (hence the "\n" at the start and the Add operation) I then print it by doing a call to Show Text: "\V[x]". The issue is, the string prints but it does not seem to convert the escaped colors (though oddly enough its interpreting the "\n" correctly). It just prints "C[4]some text hereC[0]" instead, seemingly just stripping off the '\'. I've tried adding a double "\\" but then it just prints "\C[x]". Any ideas on what's going on?



    The '\V[x]' code is parsed by the 'convertEscapeCharacters' function which will insert the stored text into the message to be displayed and then move on. Unfortunately, by that point the font color escape code has arrived too late in the process.


    Window_Base.prototype.convertEscapeCharacters = function(text) {

    // The following lines contain important text replacement functions
    // which prepare the escape codes for the 'processCharacter' function
    // later on.
    text = text.replace(/\\/g, '\x1b');
    text = text.replace(/\x1b\x1b/g, '\\');

    // Your variable is inserted into the message here, missing the
    // important text replacement above.
    text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
    }.bind(this));

    text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
    return this.actorName(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
    return this.partyMemberName(parseInt(arguments[1]));
    }.bind(this));
    text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
    return text;
    };




    So if you want the escape code to work, you will need to perform the text replacement manually. Just prepend the code with '\x1b' and everything will work snazzily. Example : \x1bC[x]
  13. How do you change a parameter of an enemy in battle? I have been doing it via BattleManager but when I change the target's atk for example it just returns to it's original atk value. Is there a way to permanently change it via a script?
  14. Milena said:
    How do you change a parameter of an enemy in battle? I have been doing it via BattleManager but when I change the target's atk for example it just returns to it's original atk value. Is there a way to permanently change it via a script?



    You could use $dataEnemies for a quick and dirty solution, but please be aware that changing the HP or property for any enemy there will be global.

    Code:
    // enemyId - The ID of the enemy as listed in Database > Enemies
    // paramId - 0 (HP)
    //         - 1 (MaxMP)
    //         - 2 (Attack)
    //         - 3 (Defense)
    //         - 4 (Magic Attack)
    //         - 5 (Magic Defense)
    //         - 6 (Agility)
    //         - 7 (Luck)
    $dataEnemies[enemyId].params[paramId] = value
  15. Hi, I am using Hudell's plugin for auto-save and I want to be able to change the name of only the save slot on which the file is autosaved.
    I have tried using the ChangeSaveFileName plugin, but it changes the naming format for all the saves.

    Suppose I want save file 1 to be named as Autosave, and the other slots won't get affected.
    What is the best way to achieve this?
  16. Please use the JS/Plugin Support forum for help with plugins.
  17. RishigangiX said:
    Hi, I am using Hudell's plugin for auto-save and I want to be able to change the name of only the save slot on which the file is autosaved.
    I have tried using the ChangeSaveFileName plugin, but it changes the naming format for all the saves.

    Suppose I want save file 1 to be named as Autosave, and the other slots won't get affected.
    What is the best way to achieve this?



    I created an add-on plugin for Hudell's Orange Auto-Save plugin that should do what you are after. Remember to place the add-on underneath the Orange Auto-Save plugin.


    Orange Auto-Save - Extra Options
  18. Exhydra said:
    I created an add-on plugin for Hudell's Orange Auto-Save plugin that should do what you are after. Remember to place the add-on underneath the Orange Auto-Save plugin.


    Orange Auto-Save - Extra Options


    Hey thanks, this works like a charm. ^^
    I will be using it and crediting you in my project.
  19. Exhydra said:
    You could use $dataEnemies for a quick and dirty solution, but please be aware that changing the HP or property for any enemy there will be global.



    // enemyId - The ID of the enemy as listed in Database > Enemies
    // paramId - 0 (HP)
    // - 1 (MaxMP)
    // - 2 (Attack)
    // - 3 (Defense)
    // - 4 (Magic Attack)
    // - 5 (Magic Defense)
    // - 6 (Agility)
    // - 7 (Luck)
    $dataEnemies[enemyId].params[paramId] = value



    It sort of works, thanks. But, does this only come up with the present troop? I mean, if I face the same troop, would they still have their database data or permanently different?


    Another question:


    Is there a way to tag a skill that both an enemy and an actor can execute?
    For example, I want to tag a skill: 


    <steal>
    atk: 10
    </steal>


    What it does is that when the Actor / Enemy executes it, the Actor / Enemy gains the value 10 (from the atk tag) permanently. So that means it adds 10 to the ATK parameter permanently, not only in battle. Then, while it adds 10 to the user, it removes 10 to the target. This shows the illusion as if the user stole the parameters from the target.
  20. This is essentially what I'm trying to do:


    Actor ID #1 uses a Skill which performs the following:


    $gameActors.actor($gameVariables.value(29)).addState(72);


    Then a common event plays which does the last bit of the skill:


    $gameVariables.setValue(30, $gameParty.members()[0].actorId());


    if ($gameVariables.value(30) === $gameVariables.value(29)) {


    $gameParty.members()[0].startAnimation(140);


    }


    $gameVariables.setValue(31, $gameParty.members()[1].actorId());


    if ($gameVariables.value(31) === $gameVariables.value(29)) {


    $gameParty.members()[1].startAnimation(140);


    }


    $gameVariables.setValue(32, $gameParty.members()[2].actorId());


    if ($gameVariables.value(32) === $gameVariables.value(29)) {


    $gameParty.members()[2].startAnimation(140);


    }


    $gameVariables.setValue(33, $gameParty.members()[3].actorId());


    if ($gameVariables.value(33) === $gameVariables.value(29)) {


    $gameParty.members()[3].startAnimation(140);


    }


    tldr; So basically I have a skill call a common event where the character that used a skill that has its own actor ID as variable #29 and then adds a state to that character. The second part of the skill then plays an animation on the character. But if there is no actor in that troop position I get an error. I'm also not a super advanced javascript user so please pardon me for my noobie looking script ^_^. Any help would be greatly appreciated! 


    Also I just saw this post after making my post on this topic. Sorry for double posting :(