JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 46 of 171 View original ↗
  1. I'm sorry about the stupid question but which project have text trouble? I know dras'lia have some due to text core and visual equipment. But right now i'm working on Chibo garden (
    link
    https://ashyramoonwolf.itch.io/chibo-garden
    ) I am so sorry i should have said it earlier. (I needed a little break on Dras'lia cause you know, sometime you do not know what to do next or how to continue... Also i will probably add the Chibo Garden in, so this is compatible.)
  2. ashyramoonwolf said:
    I'm sorry about the stupid question but which project have text trouble? I know dras'lia have some due to text core and visual equipment. But right now i'm working on Chibo garden (
    link
    https://ashyramoonwolf.itch.io/chibo-garden
    ) I am so sorry i should have said it earlier. (I needed a little break on Dras'lia cause you know, sometime you do not know what to do next or how to continue... Also i will probably add the Chibo Garden in, so this is compatible.)

    Ah don't worry about it bud, it wasn't a stupid question. The thing about the text was an example, as that is the only way I give one about plugin speed. It's not how fast your plugin loads, as all MV is doing is reading it and trying to perform what the plugin is telling it to do. Now how fast the plugin acts depends on a few things. It could be your device not having enough power to run it, or it may be an error within the plugins coding, or it could be conflicting with another plugin.
    ------------------------------------
    EDIT

    Didn't want to double post but I also feel like this is the place to ask this.

    Can MV read more the JS? like CSS or HTML5?
  3. Heyho!

    I need to show a message in Yanflys Battle log, like this:

    Code:
    this.push('addText', "This move was very effective!");

    Is there any way to format that text, e.g. showing it in a different color?

    Best regards!
  4. Hello, just made a new account, and my first question feels a little dumb.. I've been using YanFly's extra parameter formula plugin, and the default formula for the plugin confused me to an extent. Given the formula: HIT = (base + plus) * rate + flat... Without setting values for plus, rate, and flat in notetags (as the default base game calculates using base only, and the plugin adds the other three variables)... Wouldn't the final outcome yield zero regardless of base, since rate would be 0 and flat would be 0? Upon doing some battle tests it is clear to me that the value ends up being nonzero, as actors seem to hit their targets around the same percentage of time as when using the default base values in the main game. Just having a math moment I think, but if any of you who have experience with this plugin have some input that'd be very appreciated.
  5. I don't have that plugin currently so i can't check, but i would assume rate uses 1.0 as a default value, to avoid the 0 problem.

    I also have a small question on my own. I'm currently updating my stat-plugin to allow easy access to the new stats. What i currently have is dynamically adding getter-methods for the new stats, so if a stat 'test' is defined i could use:
    a.test()
    in a damage formula to get the value of that stat. What i want however is also be able to use
    a.test
    without the parentheses, like it is currently done with the default stats like attack. When i do that however i get the function object instead.
    This is the code i use to dynamically add the methods:
    Code:
    var code = "Game_BattlerBase.prototype." + statName + " = function() { return this.sgsStat('" + statName + "');}";
    eval(code);
    (sgsStat(name) is the actual defined getter for every stat)
    My javascript knowledge is very thin, so i don't know how i would have to change that code to also allow a.test

    Edit:
    Found out on my own (looked up how the default stats are defined in rpg_objects.js). In case any one is wondering, you use Object.defineProperties for that.
  6. Hello all!

    Non-coder here, looking for a simple condition for a conditional branch and need help with the syntax.

    The condition looks like this:

    if (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) <= 1

    where:
    x1 = game variable X
    y1 = game variable Y
    x2 = the active event's X position
    y2 = the active event's Y position

    I hope that's clear enough, thank you very much!
  7. Use event commands to compute that value and store it in a game-variable. Then use a simple conditional branch on that variable. No need for special javascript syntax. (If you put that whole formula inside the script-conditional branch it gets really long and confusing, so precomputing is what i would recommened)
  8. Thanks for the tip. For a value of just 1, it's actually manageable to do this via just a few conditional branches. I just realized.
  9. I am going crazy here. Shouldn't Math.randomInt(2)+1 return a number between 1 and 2? Instead I get 2 or 3. What's going on? To clarify, this is about damage calculation. If someone can help me out, you're a hero.
  10. Gin-Shiio said:
    I am going crazy here. Shouldn't Math.randomInt(2)+1 return a number between 1 and 2? Instead I get 2 or 3. What's going on? To clarify, this is about damage calculation. If someone can help me out, you're a hero.

    I don't have MV, but yeah, I would think so. I assume that's Math.js. The docs say:

    Return a random integer number larger or equal to min and smaller than max using a uniform distribution.

    math.randomInt(max) // generate a random integer between 0 and max

    So you should expect an integer within the interval [0, N), 0 or 1 in this case. You then add 1 to it, so you _should_ get 1 or 2. Can you post some more context around the code? Seems hard to believe that would ever return 3 unless MV isn't using Math.js (seems like it would).

    Either way it seems like max is inclusive assuming there's no funny business going on elsewhere. Do you ever see a 1? How many times have you run it to test?
  11. BigEd781 said:
    I don't have MV, but yeah, I would think so. I assume that's Math.js. The docs say:



    So you should expect an integer within the interval [0, N), 0 or 1 in this case. You then add 1 to it, so you _should_ get 1 or 2. Can you post some more context around the code? Seems hard to believe that would ever return 3 unless MV isn't using Math.js (seems like it would).

    Either way it seems like max is inclusive assuming there's no funny business going on elsewhere. Do you ever see a 1? How many times have you run it to test?

    First of all, thank you for taking your time to help me out.
    I have run plenty of rolls, and found these values to show up for the respective line:

    Math.randomInt(2) + 1 => 2, 3
    Math.randomInt(1) + 1 => 2
    Math.randomInt(2) => 0, 2
    Math.randomInt(1) => 0

    It really makes no sense, does it? This is the only thing I use for the damage calculation as well, so nothing else should be messing with it.
  12. Yeah I'm sorry, that makes no sense to me. I wish I had MV so that I could help more.
  13. @Gin-Shiio you could try to open the console and type "Math.randomInt" without calling the function to check what is actually doing.
    Could you do more tests with other numbers, like 3 and 5?
  14. Fhntop said:
    @Gin-Shiio you could try to open the console and type "Math.randomInt" without calling the function to check what is actually doing.
    Could you do more tests with other numbers, like 3 and 5?

    Yes, of course. Thank you for your time as well.

    Console Input

    Math.randomInt
    rpg_core.js:151 function (max) {
    return Math.floor(max * Math.random());
    }

    Number Tests

    Math.randomInt(3) + 5
    => 8, 9, 11 (40 rolls)



    Math.randomInt(5) + 3
    => 5, 6, 8, 9, 11 (30 rolls)



    Math.randomInt(4) + 7
    => 11, 12, 14, 15 (30 rolls)



    Math.randomInt(7) + 4
    => 6, 8, 9, 11, 12, 14, 15 (30 rolls)
  15. Well, at least the amount of distinct numbers seems to be consistent.
    Maybe you could try doing a couple of "Math.random() * num" with various "num" to see if it's working properly. PM me if you want so we don't spam the thread :D
  16. Fhntop said:
    Well, at least the amount of distinct numbers seems to be consistent.
    Maybe you could try doing a couple of "Math.random() * num" with various "num" to see if it's working properly. PM me if you want so we don't spam the thread :D

    Thanks, I will take you up on that offer. It's already way later where I am, so that probably will be tomorrow. Until then, and thank you!
  17. Hello everyone!

    Is there a function to return how many of a particular item the party has?
  18. Hello, I have a question about using JavaScript evals in the message window.
    Long story short, in my game the NPCs use some words the player may not know (they end up in a world where the locals speak a different language), but they are able to guess at what the words mean. I have the words themselves set up to be variables so the player can guess them (the player inputs - I'm using the text input plugin found here so as not to be limited to 16 characters - their guess, and that input is saved as the new value for that variable), and I have a common event that initializes them to all be the new-language words. My problem is, I don't want the words to all be either capitalized ("Hello My Name Is Bob") or not capitalized ("hello my name is bob").
    Is there a way to run a check for if the word is the first word in the sentence, and then, based on whether it is or isn't, either capitalize the first letter or not?
    An example of what I'm meaning
    Ex. \v[1] is initialized to "hello", and \v[2] is initialized to "name". The message is set to "\v[1] my \v[2] is Bob." in the editor. For \v[1] it checks if it's the first word, finds that it is, and capitalizes the H. For \v[2] it checks if it's the first word, finds that it isn't, and doesn't capitalize the N.)
    If it can't be done in the message window itself, can it be done through eventing before/after the "Show Text" command?
  19. I've heard lately that SoulPour777 was banned from the forums for passing off a stolen plugin (or plugins?) as his own. I'm struggling with the fact that I'd really like to use one of his plugins (Thomas Edison MV), but I want to make sure it isn't stolen. The General Resources thread has a Resource Blacklist thread pinned to it...is it possible to have a similar thread for plugins?
  20. Wait, we're not supposed to use Thomas Edison light plug in? Whoa, glad I read here.