JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 99 of 171 View original ↗
  1. (MV)
    Hey y'all.

    I'm using DreamX's extension to the Yanfly battle status window and I have everything *mostly* tuned how I want, but I'm having a little trouble with a specific edit.

    Currently I have my TP bar set up like this:
    f4fa54e67f41e803af49bc1be606aff0.png
    Essentially all I want to do is manipulate the font for the TP value, by changing the face.

    In the plugin, the method used to draw the TP value is as follows:

    JavaScript:
    if (!eval(paramTpHideValues)) {
        this.contents.fontSize = eval(paramCurrentValueFontSize);
               
        this.changeTextColor(this.tpColor(actor));
        this.drawText(actor.tp+"%", eval(paramTpValuesX), eval(paramTpValuesY), eval(paramTpValuesWidth), paramTpValuesAlignment);
    
        this.contents.fontSize = Yanfly.Param.BSWParamFontSize;
    }

    All I want to do is change the font face before drawText() executes, and then revert it back after drawText() executes (if necessary), but I'm having a little trouble getting that to work. This is built on the Yanfly Core and Yanfly Battle Core plugins, so if there's a function or property within Yanfly MV that can perform this, that'd also work fine.

    Any help is appreciated.
  2. SuzuPazuzu said:
    (MV)
    Hey y'all.

    I'm using DreamX's extension to the Yanfly battle status window and I have everything *mostly* tuned how I want, but I'm having a little trouble with a specific edit.

    Currently I have my TP bar set up like this:
    f4fa54e67f41e803af49bc1be606aff0.png
    Essentially all I want to do is manipulate the font for the TP value, by changing the face.

    In the plugin, the method used to draw the TP value is as follows:

    JavaScript:
    if (!eval(paramTpHideValues)) {
        this.contents.fontSize = eval(paramCurrentValueFontSize);
              
        this.changeTextColor(this.tpColor(actor));
        this.drawText(actor.tp+"%", eval(paramTpValuesX), eval(paramTpValuesY), eval(paramTpValuesWidth), paramTpValuesAlignment);
    
        this.contents.fontSize = Yanfly.Param.BSWParamFontSize;
    }

    All I want to do is change the font face before drawText() executes, and then revert it back after drawText() executes (if necessary), but I'm having a little trouble getting that to work. This is built on the Yanfly Core and Yanfly Battle Core plugins, so if there's a function or property within Yanfly MV that can perform this, that'd also work fine.

    Any help is appreciated.
    Is there any reason you can't use this.contents.fontFace?
  3. Trihan said:
    Is there any reason you can't use this.contents.fontFace?
    1640014626745.png
    Good question. That's what I tried initially but it always resulted in this, and I have no idea why.
  4. SuzuPazuzu said:
    View attachment 210359
    Good question. That's what I tried initially but it always resulted in this, and I have no idea why.
    The face you're using might size itself differently than the one that was being used before, so you may have to make the size bigger with the new one.
  5. Trihan said:
    The face you're using might size itself differently than the one that was being used before, so you may have to make the size bigger with the new one.
    They're from the same font family so I'd be surprised, but more relevantly, even if I change the font size (this.content.fontSize) right after changing the font, nothing changes.

    Scratch that, this.content.fontSize actually appears to be changing the y position of the text??
  6. What face did you try changing to?
  7. Trihan said:
    What face did you try changing to?
    I'm using Noto Sans Mono Regular as my basic font for values, and I'm trying to change to Noto Sans Mono Black. But the same thing happens even if I try to change to a font such as Arial.
  8. Huh, weird.
  9. Good evening, everyone. Quick MV question. How do I split notetags into an array? For example something like <note:3,4>. I've seen it done before but sadly I've plum forgotten how to do it.
  10. Well, if it is on item 101, then it would be: $dataItems[101].meta.note.split(","). Alternatively $dataItems[101].meta["note"].split(","). If the note name has a space in it, you'll need to use the later version.

    I am very sure that "meta" is part of RTP... If it's not get back to me
  11. bishiba said:
    Well, if it is on item 101, then it would be: $dataItems[101].meta.note.split(","). Alternatively $dataItems[101].meta["note"].split(","). If the note name has a space in it, you'll need to use the later version.

    I am very sure that "meta" is part of RTP... If it's not get back to me
    Thank you so much, yeah this worked perfectly!
  12. Greetings.
    This should be a really easy answer for the code minded.
    I have these lines of code

    if (this.isActor()) {
    if (this.isStateAffected(500)) {
    battler = $dataActors[500];
    } else {

    Now all I need is to replace the number 500 with a range of 500-1000, which would take one passive state from that range of IDs, then replaces the actors notes with those note of the ID of another actor who has the same ID number as the picked state.
    I hope to figure out some kind of variable coding magic trick or something to put in the place of the number 500 instead of having to type the code separately for 500 IDs each.
    Can anybody help me?
  13. McPaul said:
    Now all I need is to replace the number 500 with a range of 500-1000
    Holy god, you have a thousand states? Anyhow...
    if (this.states().some(element => element.id>499 && element.id<1001))
    should work for your condition.
  14. ATT_Turan said:
    Holy god, you have a thousand states? Anyhow...
    if (this.states().some(element => element.id>499 && element.id<1001))
    should work for your condition.
    Unfortunately this doesn't seem to work. Although I have very little coding knowledge so maybe I just don't know how to copy your line in properly.
    Just so if anybody would have any other suggestions, I'll try to explain my issue better.

    if (this.isActor()) {
    if (this.isStateAffected(500)) { <<<I need this to check if the state ID that the actor has is between 500-1000
    battler = $dataActors[500]; <<<<<I need this to return the exact ID number of the state itself
    } else {

    The code works fine for me, but I'd have to write these four line for each of the 500-1000 states, which isn't hard, but I think it'd be better for the code to keep the whole range in one set of lines lol
  15. McPaul said:
    Unfortunately this doesn't seem to work. Although I have very little coding knowledge so maybe I just don't know how to copy your line in properly.
    I missed the part where you wanted to get the actor of the matching ID.

    The problem with what you're asking for is that (unless you have some very strict system with these) there is a possibility that the actor will have more than one state in that range. How should this get resolved in those cases?

    Aside from that, this will do what you're asking for.
    Code:
    if (this.isActor())
    {
        var index=-1;
        if ((index=this.states().find(element => element.id>499 && element.id<1001))>-1)
            battler=$dataActors[index];
        else
  16. (MV)
    is there a script call that interprete the exact posicion in pixels and not in grids the player or a event is?Cause,well,if i am in the grid 0x,0y i must also be in the pixel 24x,24y(?) and if i move to the grid 3x,0y i should be in pixel 168x,24y(?) if i know this mentally,then probably a script call also,no?
  17. ATT_Turan said:
    I missed the part where you wanted to get the actor of the matching ID.

    The problem with what you're asking for is that (unless you have some very strict system with these) there is a possibility that the actor will have more than one state in that range. How should this get resolved in those cases?

    Aside from that, this will do what you're asking for.
    Code:
    if (this.isActor())
    {
        var index=-1;
        if ((index=this.states().find(element => element.id>499 && element.id<1001))>-1)
            battler=$dataActors[index];
        else
    Unfortunately this didn't work either, but I think I made some progress.
    I rewrote the code this way and it works like it used to while I give the index variable any of my rigged state ids.

    if (this.isActor()) {
    var index=500;
    if (this.isStateAffected(index)) {
    battler = $dataActors[index];
    } else {

    I spent a couple of hours trying to put the index variable into a range of 500-1000 with all kinds of brackets, but nothing works.
  18. McPaul said:
    Unfortunately this didn't work either, but I think I made some progress.
    I rewrote the code this way and it works like it used to while I give the index variable any of my rigged state ids.

    if (this.isActor()) {
    var index=500;
    if (this.isStateAffected(index)) {
    battler = $dataActors[index];
    } else {

    I spent a couple of hours trying to put the index variable into a range of 500-1000 with all kinds of brackets, but nothing works.
    The code from ATT_Turan did not work, because the find function does not return the index of the object in the array, but the object itself. It does return undefined, if the object cannot be found. The following amended version should work a little better:
    JavaScript:
    if( this.isActor() )
    {
        const firstAffectedStateInRange = this.states().find(element => element.id > 499 && element.id < 1001);
        if( firstAffectedStateInRange !== undefined )
        {
            battler = $dataActors[firstAffectedStateInRange.id];
        }
        else
        {
                
        }
    }
  19. BurningOrca said:
    The code from ATT_Turan did not work, because the find function does not return the index of the object in the array, but the object itself. It does return undefined, if the object cannot be found. The following amended version should work a little better:
    JavaScript:
    if( this.isActor() )
    {
        const firstAffectedStateInRange = this.states().find(element => element.id > 499 && element.id < 1001);
        if( firstAffectedStateInRange !== undefined )
        {
            battler = $dataActors[firstAffectedStateInRange.id];
        }
        else
        {
              
        }
    }
    Took me a minute to rearrange the brackets, all the while the game kept crashing at battle, but in the end it began to work, all tests passed. And there I though this would be a really simple fix.
    Thank you. I won't forget it.
  20. BurningOrca said:
    The code from ATT_Turan did not work, because the find function does not return the index of the object in the array, but the object itself.
    Thanks for the correction.

    DarielZer0 said:
    (MV)
    is there a script call that interprete the exact posicion in pixels
    $gamePlayer and events have a screenX() and screenY() method that should be what you're looking for.