A warm up for the upcoming RPG Maker MV

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
Not really, this is not valid JSON:

{  'my_callback' : function (x, y) { return x * y;  } }It is done for security reasons, you may know how dangerous are callbacks like this...

It is HTML5 (the web version) there are PC and MAC versions wich may or may not use HTML5 (they may use something like V8 inside a C++ APP)
just try this:

var callbacks = {};

callbacks.callback1 = function (x, y) { };

callbacks.callback2 = function (x, y) { };

Its like the basis for jQuery plugins.

About HTML5 looks like its only export feature... http://www.rpgmakerweb.com/products/programs/rpg-maker-mv

Anyway about prototype: check the code on the immage at the Javscript session.
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
var callbacks = {};

callbacks.callback1 = function (x, y) { };

callbacks,callback2 = function (x, y) { };
Oh no, this:

var callbacks = {   do_something: function () {   },  do_something_else: function () {  }}is totally valid javascript, it is invalid JSON.

While every piece of JSON is valid Javascript, the inverse is not true.

JSON is not really javascript's true object notation inside javascript, it is a subset to pass information between PCs.

You know, how JSON does not allow also:

{ a_property_unquoted: 23 }you always have to quote:

Code:
{ 'a_property_unquoted': 23 }
 

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
Oh no, this:

var callbacks = {   do_something: function () {   },  do_something_else: function () {  }}is totally valid javascript, it is invalid JSON.

While every piece of JSON is valid Javascript, the inverse is not true.

JSON is not really javascript's true object notation inside javascript, it is a subset to pass information between PCs.

You know, how JSON does not allow also:

{ a_property_unquoted: 23 }you always have to quote:

{ 'a_property_unquoted': 23 }
Its valid from my point of view, even thou I understand your point, its meant for data manipulation, in which case function is not data.

But I'm pretty sure you understood mine, there are always turn arounds, like the seccond notation for accessing properties:

myJson = {};

myJson[propertyVariable] = 23;
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
Yes, just remember than if you try to use JSON.stringify with a function or recursive objects, it will throw an error.

The alternate property access is the main reason why

array[0] is really 

array['0']and 

matrix[1, 2]is not possible in javascript...
 

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
Yes, just remember than if you try to use JSON.stringify with a function or recursive objects, it will throw an error.

The alternate property access is the main reason why

array[0] is really 

array['0']and 

matrix[1, 2]is not possible in javascript...
As I told, I agree about function not being data, but its not like we would pass a json to another language in RPM VM, neither saving a function in the database why would I use stringify in this case?

I agree about array[0] being array['0'], said nothing against it.

All I said is that we can still access the property using a value stored in another variable, instead of using the string literal.

About matrix[1, 2] I dont see the relation :/

BTW its getting too offtopic hahaha, better follow with the tips
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
Well, Imagine this:

var rpg.skills.fireball = {  id: 1,  element: rpg.elements.fire,   damageFormula: function (user, target) {      return user.mat * 3 - target.mdf;  } /* more here...  */}This is really a great way to make skills with some flexibility, adding callbacks and such will provide that you can change it later with another function or or use any type of parameter.

You can do any valid expression inside an alternate property access:

obj[ 2 * 3 + myFuncall() + 'a-b' + id & false || undefined ]is valid.

It is true you will usually use a variable, or a literal string if the name starts with @ or a number..

But the tables you use in RGSS, cannot be used as before, you can't implement operator overload now...

This doesn't mean you cant create a Tileset of course, its more about being expressive and idiomatic in code (wich ruby is great at that)
 

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
Well, Imagine this:

var rpg.skills.fireball = {  id: 1,  element: rpg.elements.fire,   damageFormula: function (user, target) {      return user.mat * 3 - target.mdf;  } /* more here...  */}This is really a great way to make skills with some flexibility, adding callbacks and such will provide that you can change it later with another function or or use any type of parameter.

You can do any valid expression inside an alternate property access:

obj[ 2 * 3 + myFuncall() + 'a-b' + id & false || undefined ]is valid.

It is true you will usually use a variable, or a literal string if the name starts with @ or a number..

But the tables you use in RGSS, cannot be used as before, you can't implement operator overload now...

This doesn't mean you cant create a Tileset of course, its more about being expressive and idiomatic in code (wich ruby is great at that)
Sorry, I dont understand.

I didnt argue about overloading, Im just discussing ways to declare a function inside a json object.

Anyway I could not agree more, ruby is such a beautiful thing and I preffer it over JS, its reflective capatibilities are remarcable and will be missed.
 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
I really hope that we can use Coffeescript without much troubles when writing new plugins. If you come from ruby or phyton you would have less trouble with using Coffeescript than JavaScript. Since Coffescript compiles into JavaScript you could also use it as a bridge while you are learning JavaScript. But I am also looking forward to see how they have used Javascript to build the new "Classes" and so on.
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
I really hope that we can use Coffeescript without much troubles when writing new plugins. If you come from ruby or phyton you would have less trouble with using Coffeescript than JavaScript. Since Coffescript compiles into JavaScript you could also use it as a bridge while you are learning JavaScript. But I am also looking forward to see how they have used Javascript to build the new "Classes" and so on.
I would prefer to use an ES6 to ES5 compiler like traceur insthead.

Coffescript has many little problems on itself, but that is because for of.. and new things will be implemented over time.

Firefox already supports the short expression for functions:

(x) => x * xSo sooner or later CS will not have any 'real' advantage, and try to remember the difference between

(x) -> x * x and

(x) => x * xin coffee script

 

 

That is soooo small I can barely noteice the code.

(people says it has properties like Width and Height, wich seems weird if they start with an uppercase letter)

 

 

 
 
Last edited by a moderator:

Lantiz

Biterkid
Veteran
Joined
Dec 29, 2012
Messages
719
Reaction score
1,069
First Language
Portuguese
Primarily Uses
RMMV
That is soooo small I can barely noteice the code.

(people says it has properties like Width and Height, wich seems weird if they start with an uppercase letter)
Zoom ftw!

Joking...

yeah its small, but I can understand some parts: I can read "prototype" there hahahaha
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
Window_TitleCommand.prototype.updatePlacement = function (offsetX, offsetY) { ...After all this years, they STILL insist in using ClassType_ClassName...

At least, they are consistent in something
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,076
First Language
English
Window_TitleCommand.prototype.updatePlacement = function (offsetX, offsetY) { ...After all this years, they STILL insist in using ClassType_ClassName...
At least, they are consistent in something
Seems reasonable. Would you prefer something else?
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
860
Reaction score
366
First Language
Spanish
well, you know, maybe a:

Window.TitleCommand is a little more according to javascript standar practices.

Don't take it as the worst thing ever, it is great they still use some things similar to VXA, this should help people to not cry (a lot) in the conversion.

People will still need to learn about prototype anyway...
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I usually don't enjoy survival games, but I absolutely love Conan Exiles.
Basically Everyone: Dont make a long game the first time. Me: I guess i'll make a REALLY long game in that case >:p
I've developed a habit of thanking cleaning ladies for their work.
Sorry Aerith... I will abandon your shoes... :guffaw:
Spent a whole bunch of time today reworking the area in the video because someone said it was too illusory. So I reworked it so it changes less, moved the grass up to the same level as the player.... And found enough extra resources to make the grass moves when the player touches it. Also lots more water, because it looks amazing. I'll probably put up a short updated video later today.

Forum statistics

Threads
95,771
Messages
931,768
Members
126,170
Latest member
2969910490
Top