JavaScript questions that don't deserve their own thread

ashyramoonwolf

Chibo's Keeper
Veteran
Joined
Oct 22, 2017
Messages
206
Reaction score
142
First Language
french
Primarily Uses
RMMV
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 ( ) 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.)
 
Joined
Sep 1, 2017
Messages
103
Reaction score
51
First Language
English
Primarily Uses
RMMV
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 ( ) 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?
 
Last edited:

hyuugacln

Veteran
Veteran
Joined
Sep 22, 2016
Messages
98
Reaction score
81
First Language
German
Primarily Uses
RMMV
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!
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

MagicMagor

Veteran
Veteran
Joined
Apr 7, 2012
Messages
201
Reaction score
38
First Language
German
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.
 
Last edited:

Ravenith

Veteran
Veteran
Joined
Mar 27, 2012
Messages
263
Reaction score
15
First Language
Greek
Primarily Uses
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!
 

MagicMagor

Veteran
Veteran
Joined
Apr 7, 2012
Messages
201
Reaction score
38
First Language
German
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)
 

Ravenith

Veteran
Veteran
Joined
Mar 27, 2012
Messages
263
Reaction score
15
First Language
Greek
Primarily Uses
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.
 

Biestmann

Studio Biest
Veteran
Joined
May 18, 2015
Messages
402
Reaction score
655
First Language
German
Primarily Uses
RMMV
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.
 

BigEd781

undefined method 'stupid_title' found for nil:NilC
Veteran
Joined
Mar 1, 2012
Messages
940
Reaction score
304
First Language
Dothraki
Primarily Uses
N/A
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?
 

Biestmann

Studio Biest
Veteran
Joined
May 18, 2015
Messages
402
Reaction score
655
First Language
German
Primarily Uses
RMMV
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.
 

BigEd781

undefined method 'stupid_title' found for nil:NilC
Veteran
Joined
Mar 1, 2012
Messages
940
Reaction score
304
First Language
Dothraki
Primarily Uses
N/A
Yeah I'm sorry, that makes no sense to me. I wish I had MV so that I could help more.
 

Fhntop

Villager
Member
Joined
May 4, 2017
Messages
28
Reaction score
22
First Language
Spanish
Primarily Uses
RMMV
@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?
 

Biestmann

Studio Biest
Veteran
Joined
May 18, 2015
Messages
402
Reaction score
655
First Language
German
Primarily Uses
RMMV
@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)
 

Fhntop

Villager
Member
Joined
May 4, 2017
Messages
28
Reaction score
22
First Language
Spanish
Primarily Uses
RMMV
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
 

Biestmann

Studio Biest
Veteran
Joined
May 18, 2015
Messages
402
Reaction score
655
First Language
German
Primarily Uses
RMMV
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!
 

Artomes

Veteran
Veteran
Joined
Jun 3, 2016
Messages
45
Reaction score
5
First Language
English
Primarily Uses
N/A
Hello everyone!

Is there a function to return how many of a particular item the party has?
 
Last edited:
Joined
Feb 18, 2015
Messages
447
Reaction score
195
First Language
English
Primarily Uses
RMMV
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?
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?
 

Llareian

Jack of All Trades, Master of None
Veteran
Joined
Jan 26, 2017
Messages
603
Reaction score
1,400
First Language
English
Primarily Uses
RMMV
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?
 

Sauteed_Onion

Mmm Tasty
Veteran
Joined
Dec 13, 2017
Messages
554
Reaction score
3,666
First Language
English
Primarily Uses
RMMV
Wait, we're not supposed to use Thomas Edison light plug in? Whoa, glad I read here.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I was doing forge runs on D2 with my wife last night, and singing like a leprechaun to annoy her XD. I was calling it 'The Farge'
Is i possible too make a weapon have a chance of using a skill?
Can the Eternal Dreamers finish off the final boss? We'll see!
Fekken kill me. I unknowingly swapped out two important events's codes and saved the game to test it. I'm just doing this for fun and the fun has now been replaced with excruciating torture.
Is this how game developers feel all the time?

EDIT:
WAIT HOLY S***
MY LAST POST ASKING FOR HELP ON AN EVENT ACTUALLY SAVED IT
OH MY GOD
Coffee + Silk Coconut Milk + Splenda Zero = Not ..... awful :/ .

Forum statistics

Threads
94,448
Messages
921,011
Members
124,271
Latest member
lymeish
Top