ES6 Questions.

Driftwood Gaming

For just $1 a day you can prevent forest fires...
Veteran
Joined
Nov 11, 2015
Messages
119
Reaction score
306
First Language
English
Primarily Uses
RMMV
Which functions and shorthand of ES6 are currently being utilized by the MV Engine? It seems like some things work and some don't.


This is a topic for people to post what they have tested and what currently works.
 

taarna23

Marshmallow Princess
Global Mod
Joined
Jul 20, 2012
Messages
2,402
Reaction score
4,969
First Language
English
Primarily Uses
RMMZ
That's actually a good question... I ended up using some Array or String (can't recall which) functions that were apparently ES6, and they worked as expected. Later I found out they were ES6 functions and redid them, just in case. Specifically, I used .includes.


Array.includes


String.includes


The MV developers may have included the provided polyfill somewhere in the MV code - I have not searched it all that extensively. If so, I imagine it would be somewhere in rpg_core in JsExtensions.
 

Driftwood Gaming

For just $1 a day you can prevent forest fires...
Veteran
Joined
Nov 11, 2015
Messages
119
Reaction score
306
First Language
English
Primarily Uses
RMMV
Just tested another ES6 shorthand in MV, and it works. (Using Template Literals) 
var name = 'mike';                      //single quotes here still to declare a string.
$gameMessage.add(`My name is ${name}.`);         //it just looks cleaner.


This is using back ticks (`) instead of single quotes (') i know they look the same but the back tick is the ~ key.


Instead of writing:


var name = 'mike';


$gameMessage.add('My name is' + name + '.');    //messy.
 
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
795
First Language
English
Primarily Uses
RMMV
I actually created a list of what works concerning ES6, there are some more features, but these are some.


@Driftwood Gaming


In terms of short hands:

  • Object shorthands
  • Template literals



Here are the object short hands


var name = "Ryan";
var age = 34;

var person = {
name,
age,
sayName() {
console.log(`Hello my name is ${name}`);
}




If you have a variable with a specific name, you can just pass the variable into the object to use as a key.


You also can declare functions within an object like sayName above.
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,015
Messages
1,018,351
Members
137,801
Latest member
topsan
Top