JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 76 of 171 View original ↗
  1. PauloHPBender said:
    Howdy, partners!

    How do I store an Actor's name into a variable?

    I tried to use the "Control Variables" command with the Script option below, with no success...View attachment 158379

    Try using

    $gameActors._data[9]._name;

    /Edit:

    Now that I looked at it, your method works too, but you forgot the brackets at the end:

    $gameActors.actor(9).name();
  2. Lanzy said:
    Try using

    $gameActors._data[9]._name;

    /Edit:

    Now that I looked at it, your method works too, but you forgot the brackets at the end:

    $gameActors.actor(9).name();
    Thanks a lot, I never meddled with script calls before, so I don't know much about syntaxes and terms yet.
  3. Hello!
    I have YEP_AbsorptionBarrier and YEP_X_ItemDurability and I'm trying to set the absorption points through a skill equal to the durability points of the user's equipped armor in their third equipment slot. I'm pretty garbage at coding and couldn't figure it out.
    I tried:
    JavaScript:
    <Custom User Barrier>
    value = user.equips[3].durability;
    </Custom User Barrier>

    But it didn't work. Any help would be appreciated! :D
  4. SmashArtist said:
    Hello!
    I have YEP_AbsorptionBarrier and YEP_X_ItemDurability and I'm trying to set the absorption points through a skill equal to the durability points of the user's equipped armor in their third equipment slot. I'm pretty garbage at coding and couldn't figure it out.
    I tried:
    JavaScript:
    <Custom User Barrier>
    value = user.equips[3].durability;
    </Custom User Barrier>

    But it didn't work. Any help would be appreciated! :D

    I'm not familiar with that plugin, but I do know that you need to use round brackets for equips:

    value = user.equips()[3].durability

    Maybe that helps.
  5. Tried it out, unfortunately that didn't work either.
    Here's the error showing up in the console:
    Code:
    TypeError: Cannot read property 'durability' of undefined
    So durability is probably not the word I'm looking for, but I'm not sure what is.
    Thanks @Lanzy for your help anyways, I'll be waiting for someone to help me with a solution.
  6. SmashArtist said:
    Tried it out, unfortunately that didn't work either.
    Here's the error showing up in the console:
    Code:
    TypeError: Cannot read property 'durability' of undefined
    So durability is probably not the word I'm looking for, but I'm not sure what is.
    Thanks @Lanzy for your help anyways, I'll be waiting for someone to help me with a solution.

    I tried to look a little into the Yanfly Plugins, but I couldn't find an answer.
    The only thing I can tell you is that the error message doesn't mean it couldn't find the value 'durability'.
    But rather that it couldn't find either user or user.equips()[3]. It could be that it's checking the equips when there is nothing equipped.

    So to avoid an error when there is nothing found for the value, you can try this:

    JavaScript:
    <Custom User Barrier>
    
    if (user && user.equips()[3] && user.equips()[3] !== null) {
      value = user.equips()[3].durability || 0; //in case there is no durability value it will take 0 instead
    }
    </Custom User Barrier>

    If that doesn't work then you should open a thread about this.
    Best of luck.
  7. So it turns out I was checking the wrong equip slot. For slot 3 I should have been using user.equips()[2].
    While I will have the skill require you have something equipped to slot 3, I will also add in that code you mentioned just to be safe.
    I may have some other javascript questions soon, but for now this is solved! :kaojoy:
    Thank you for your help!
  8. Hi everyone! I have a question regarding Window_Selectable and rect.
    Lets say i use setBackgroundType(2) so the Window_Selectable(Window_BattleStatus in this case) is transparent, but now i want to apply windowskin to the selectable items/rect(actor selection).

    Can i do that? If yes, can you show me how? Thanks!
    Below i attach the image.
  9. boringprotagonist said:
    Hi everyone! I have a question regarding Window_Selectable and rect.
    Lets say i use setBackgroundType(2) so the Window_Selectable(Window_BattleStatus in this case) is transparent, but now i want to apply windowskin to the selectable items/rect(actor selection).

    Can i do that? If yes, can you show me how? Thanks!
    Below i attach the image.

    So the windows are set to transparent, while you want to change the cursor's skin?
    But the cursor is still visible when the windows are transparent. I don't get it.

    How well do you know javascript?

    Please elaborate. Thanks.
  10. Lanzy said:
    So the windows are set to transparent, while you want to change the cursor's skin?
    But the cursor is still visible when the windows are transparent. I don't get it.

    How well do you know javascript?

    Please elaborate. Thanks.
    Hi Lanzy, sorry i didnt make myself clear enough.
    What i want to achieve is to make individual window for each actor on Window_BattleStatus. My approach is to just load a windowskin on itemRect lol, but i dont know if its possible. I dont want to create a new window object so i dont need to modify scene_battle :(

    I think i can handle quite a bit of javascript, been practicing OOJS by modifying MV base code. Made a game with p5.js

    Thanks for replying!
  11. boringprotagonist said:
    Hi Lanzy, sorry i didnt make myself clear enough.
    What i want to achieve is to make individual window for each actor on Window_BattleStatus. My approach is to just load a windowskin on itemRect lol, but i dont know if its possible. I dont want to create a new window object so i dont need to modify scene_battle :(

    I think i can handle quite a bit of javascript, been practicing OOJS by modifying MV base code. Made a game with p5.js

    Thanks for replying!

    //Edit:
    You might encounter loading issues, like the newly loaded window skin only changes when you moved the cursor once or so. If that happens let me know.

    Ok I think I understand now.
    You won't have to make a new window for every actor. You can change the window skin of a window during the game. So you can set the condition to whatever actor is currently the menu actor and then change the window skin accordingly.

    For example:

    JavaScript:
    Window_Base.prototype.loadWindowskin = function() {
        this.windowskin = ImageManager.loadSystem(windowSkin);
    };
    
    Window_Base.prototype.loadWindowskin2 = function() {
        this.windowskin = ImageManager.loadSystem(windowSkin2);
    };
    
    if ($gameParty._menuActorId === 1) {
        SceneManager._scene._statusWindow.loadWindowskin2(); //don't know exactly if _statusWindow is the correct name
    }

    Does this help?
  12. Lanzy said:
    Ok I think I understand now.
    You won't have to make a new window for every actor. You can change the window skin of a window during the game. So you can set the condition to whatever actor is currently the menu actor and then change the window skin accordingly.

    For example:

    JavaScript:
    Window_Base.prototype.loadWindowskin = function() {
        this.windowskin = ImageManager.loadSystem(windowSkin);
    };
    
    Window_Base.prototype.loadWindowskin2 = function() {
        this.windowskin = ImageManager.loadSystem(windowSkin2);
    };
    
    if ($gameParty._menuActorId === 1) {
        SceneManager._scene._statusWindow.loadWindowskin2(); //don't know exactly if _statusWindow is the correct name
    }

    Does this help?
    Oh yes that certainly help, now i know i can load several windowskins!
    But its not exactly what i want to achieve though, sorry English isnt my main language so i cant convey it better.

    What i want to do is to load windowskin on actor name/hp/mp area (bottom part of the picture). But i dont want to load it as a single window that span across all actors like in default battle menu, i want to make it so each actor name/hp/mp area has its own window. So there will be 4 windows.
    The bottom part is actually just Window_BattleStatus but i use setBackgroundType(2) and each actor name/hp/mp area is just the Window_BattleStatus items/selection.

    So in essence, i want to load windowskin on Window_BattleStatus items/selection. Which i believe the code is on Window_Selectable.prototype.itemRect?

    Thanks Lanzy!
  13. boringprotagonist said:
    Oh yes that certainly help, now i know i can load several windowskins!
    But its not exactly what i want to achieve though, sorry English isnt my main language so i cant convey it better.

    What i want to do is to load windowskin on actor name/hp/mp area (bottom part of the picture). But i dont want to load it as a single window that span across all actors like in default battle menu, i want to make it so each actor name/hp/mp area has its own window. So there will be 4 windows.
    The bottom part is actually just Window_BattleStatus but i use setBackgroundType(2) and each actor name/hp/mp area is just the Window_BattleStatus items/selection.

    So in essence, i want to load windowskin on Window_BattleStatus items/selection. Which i believe the code is on Window_Selectable.prototype.itemRect?

    Thanks Lanzy!
    //Edit:
    You could also just draw costumized Names, gauges, images etc. over the transparent status window.


    Loading a windowskin on an itemRect won't work, because windowskin property is only for window classes.
    Window and Rectangle are different classes from different super classes. I guess it wouldn't work for you if you just add an image behind every actor selection?

    Anything else would be not impossible, but very complicated.
  14. Lanzy said:
    //Edit:
    You could also just draw costumized Names, gauges, images etc. over the transparent status window.


    Loading a windowskin on an itemRect won't work, because windowskin property is only for window classes.
    Window and Rectangle are different classes from different super classes. I guess it wouldn't work for you if you just add an image behind every actor selection?

    Anything else would be not impossible, but very complicated.
    Ah i see, so its not possible to load windowskin on itemRect. And yeah perhaps i can just add images behind every actor selection, but i prefer using window because i want to use windowskin :hhappy:
    I guess i should study Window_Selectable first to figure it out.

    Thanks a lot Lanzy, you saved me from hours of frustration lol.
  15. boringprotagonist said:
    Ah i see, so its not possible to load windowskin on itemRect. And yeah perhaps i can just add images behind every actor selection, but i prefer using window because i want to use windowskin :hhappy:
    I guess i should study Window_Selectable first to figure it out.

    Thanks a lot Lanzy, you saved me from hours of frustration lol.

    I don't want to discourage you, but as someone who has spent many hours on this: Changing windows, especially if you want to make multiple ones, replacing another one (status window) is not a good way for a beginner to start. If you want to learn more about windows, I recommend trying to code your own menu or a costum window at first, just to understand the basics.

    The battle flow is dependent on window properties, such as visibility, activeness, etc. Meaning that when you replace the status window with 4 seperate windows, you will have to rewrite the entire battle flow for it to consider the 4 costum windows. Otherwise it will only check for status window and disrupt the flow, when it can't find it.

    The Battle Engine is a pain in the ***

    If you need any help with sprites or images, let me know. I would rather create 100 images behind the window, than messing with the battle engine.

    Good Luck!
  16. Hello everyone,

    I am using RPG Maker MV and was wondering how to address the actor's current TP in a conditional branch, and add a State if the TP is 50 or higher/remove a state if it's 49 or lower. There is no need to figure out which actor, as there is only one actor in my game. I've tried the GUI options, but I can only check their HP via the Troops event system, and I can't address current stats at all from the regular event menu. This makes me think I need to use the Script command, and call a comparison, but I'm not sure what "current actor's current TP" is called internally or how to script that.
  17. Is this what you are looking for?
    Lc7pXJu.png
    you have to replace the "1" in the script with the database id of your character (if it isn't the first one)
  18. kiriseo said:
    Is this what you are looking for?
    Lc7pXJu.png
    you have to replace the "1" in the script with the database id of your character (if it isn't the first one)

    Thanks for the reply. I tested the script exactly as you've written it (testing with actor 0001: player_1, and the status Berserk) and got no results. I started a test battle, got my player's TP to 50, 75, 100, and the script never ran.

    Page 1 (Conditions: Turn End, Span: Battle)
    If: Script: $gameActors.actor(1)._ tp >= 50
    Change State: player_1, + BERSERK
    :Else
    Change State: player_1, - BERSERK
    :End
  19. Sketchward said:
    Thanks for the reply. I tested the script exactly as you've written it (testing with actor 0001: player_1, and the status Berserk) and got no results. I started a test battle, got my player's TP to 50, 75, 100, and the script never ran.

    Page 1 (Conditions: Turn End, Span: Battle)
    If: Script: $gameActors.actor(1)._ tp >= 50
    Change State: player_1, + BERSERK
    :Else
    Change State: player_1, - BERSERK
    :End

    change the span to Turn instead of Battle so that the event with the script runs once every turn instead of once every battle
  20. kiriseo said:
    change the span to Turn instead of Battle so that the event with the script runs once every turn instead of once every battle
    Yep that fixed it, works perfectly now. Thanks very much