MVCommons - The community core plugin

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
The MVCommons
The current version is: 1.5.0
Hello! Congratulations on getting RPG Maker MV! During the last month with the demo available, me and my team have been working on getting a core plugin that is intended to be used by the community ready for release. Now that RMMV has been released, it's time to release the core plugin so that developers can begin to use it.

What's the point of it?

The point of having a community core script is compatibility. In Ace (and below!), there were many issues where core scripts from different people clashed, and caused incompatibilities. One of the most notable of these was Victor's. In an attempt to solve this issue and not have the same thing happen with MV, we have prepared this core script that has functionality we believe will be common to all plugins.

Who runs this? Can I request something?

The plugin is intended to be maintained by the community. The plugin has been released to the public domain. This means it's free for commercial and non-commercial use, and no attribution (credit) is required. We want the plugin to be used in as many places as possible, so we didn't restrict it in any way.

Anyone may request a feature be added, however, please keep in mind that this is geared towards plugin creators and does not directly add or modify any features of the game itself. To request something be added, changed, or removed, please report an issue on GitHub (this requires a GitHub account). We will discuss the changes there before making any decision. If we feel it is important enough, we will also move the discussion and final decision to a more public location, possibly these forums.

Where is it?

The plugin is publicly hosted on GitHub. Please feel free to download the MVCommons.js file, and include it with your project!

Please press the "Raw" Button before saving the file! You may either right click the button and select "Save Link As...", or left click and press Ctrl + S or CMD + S to save the file that way. Saving directly from the link will cause issues with errors such as "Unexpected token <", causing the plugin to fail to load!

License

This script is released to the public domain. There are no copyright holds, no terms of use. You may use this plugin in any project, commercial or not. You may also take this plugin, modify it, or not, and release it a your own.
 
Last edited by a moderator:

tati light

Veteran
Veteran
Joined
Aug 15, 2015
Messages
160
Reaction score
110
First Language
English
Primarily Uses
Thanks very much for this! I greatly appreciate this. Once I learn about Javascript, I will try to help as well.
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,186
Reaction score
1,444
First Language
Portuguese
How far we've come! And yesterday we were using SephirothSpawn's SDK!
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
How far we've come! And yesterday we were using SephirothSpawn's SDK!
This is nothing like the SDK. If you want to compare it with something, this is like the MACL... It doesn't break the structure like the SDK did...
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,186
Reaction score
1,444
First Language
Portuguese
...That's exactly the point of my commentary?
 

Seriel

Veteran
Veteran
Joined
Aug 16, 2014
Messages
3,013
Reaction score
504
First Language
English
Primarily Uses
Other
This is nothing like the SDK. If you want to compare it with something, this is like the MACL... It doesn't break the structure like the SDK did...
I believe JosephSeraph meant this is better than the old SDK and that we've moved on.

Right?
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,186
Reaction score
1,444
First Language
Portuguese
Exactly, I meant that yesterday we were using that messy SDK (which was still brilliant for something designed for months after the first ruby based rpg maker had been launched in the western world), then we abandoned sdks, on the vxa era we embraced Core scripts and now we have a Community Core!
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,218
Reaction score
448
First Language
indonesian
just learning javascript and confused... i want to use the deepClone function from this core script but not sure how to use it :D .

anyone can help ?

example:

Game_Map.prototype.save_cur_map = function() {    $gameSystem._est_resaved_map[this._mapId] = this._events;};i want to change this._events to the deep clone of it...

sorry for newbie question... just learning javascript today (and self learning too >.<)

i already try

$.deepClone(this.events);

this.events.deepClone();
 
Last edited by a moderator:

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,680
First Language
Java's Crypt
Primarily Uses
RMMZ
just learning javascript and confused... i want to use the deepClone function from this core script but not sure how to use it :D .

anyone can help ?

example:

Game_Map.prototype.save_cur_map = function() {    $gameSystem._est_resaved_map[this._mapId] = this._events;};i want to change this._events to the deep clone of it...
sorry for newbie question... just learning javascript today (and self learning too >.<)
Just call MVCommons.deepClone or MVC.deepClone for short:

Code:
Game_Map.prototype.save_cur_map = function() {    $gameSystem._est_resaved_map[this._mapId] = MVCommons.deepClone(this._events);};
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,218
Reaction score
448
First Language
indonesian
Just call MVCommons.deepClone or MVC.deepClone for short:

Game_Map.prototype.save_cur_map = function() { $gameSystem._est_resaved_map[this._mapId] = MVCommons.deepClone(this._events);};
somehow it throw

reference error...

object is not defined...

i install the MVCommon plugin above my plugin...
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
somehow it throw

reference error...

object is not defined...

i install the MVCommon plugin above my plugin...
whoops This seems to be a little bug on our end. Please give us a second to clean that up and we'll upload a fixed version. Sorry for the inconvenience, it's been a bit hectic making sure we've got the right version, as there's 4 of us working on it and we're all relatively new to Git.
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,218
Reaction score
448
First Language
indonesian
whoops This seems to be a little bug on our end. Please give us a second to clean that up and we'll upload a fixed version. Sorry for the inconvenience, it's been a bit hectic making sure we've got the right version, as there's 4 of us working on it and we're all relatively new to Git.
thanks for the info... so when the core is fixed... we can use the method above...

btw i did find workaround for my simple first plugin without needing deep clone. but who knows when i do need them later...
 

babykgar

Villager
Member
Joined
Oct 19, 2015
Messages
14
Reaction score
1
First Language
English
@Zalerinian,

MVC.Boolean("hello");Or,

MVC.Boolean('hello'); Either causes an error. The offending function:

/** * Converts the string to a boolean. Any string except 'true' will return * false. * @param str The string to compare to true. */ function boolFunc(str) { return Function("return " + str + " === true")(); }The core error message is 

"ReferenceError: hello is not defined"Recommended change:

Code:
    function boolFunc(str) {        return Function("return '" + str + "' === 'true'")();    }
 
Last edited by a moderator:

babykgar

Villager
Member
Joined
Oct 19, 2015
Messages
14
Reaction score
1
First Language
English
It looks like a lot of DataManager's functions are undefined. I noticed a lot of functions missing, so I tried just calling them in-game, and here's what I got in the console: 

Code:
DataManager.localContentPathundefinedDataManager.storageFileExistsundefinedDataManager.directoryExistsundefinedDataManager.removeDirectoryundefinedDataManager.storageSaveFileundefinedDataManager.storageLoadFileundefinedDataManager.storageRemoveFileundefined
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
@Zalerinian,

MVC.Boolean("hello");Or,

MVC.Boolean('hello'); Either causes an error. The offending function:

/** * Converts the string to a boolean. Any string except 'true' will return * false. * @param str The string to compare to true. */ function boolFunc(str) { return Function("return " + str + " === true")(); }The core error message is 

"ReferenceError: hello is not defined"Recommended change:

function boolFunc(str) { return Function("return '" + str + "' === 'true'")(); }
Do you actually have a variable called hello ? If you are planning to get a parameter you should still do:

Plugin.parameters('PluginName')['paramName']MVC.Boolean is meant to convert strings like 'true' or 'false'.

Anyway now an undefined variable won't crash it, but it will give you false. so... *FIXED*

Could you also paste a console log with the trace of the error please? (Press F8)
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
Do you actually have a variable called hello ? If you are planning to get a parameter you should still do:

Plugin.parameters('PluginName')['paramName']MVC.Boolean is meant to convert strings like 'true' or 'false'.
While this is true, also keep in mind that it does allow you to check the values of global variables, but you need to make sure the expression itself results in true or false. The function is intended for checking if a parameter is true. This way, you can set some portions of your plugins to only be enabled if a certain condition in true. Now, while this does work for basic things like if a certain variable is a certain value or some such stuff, it's better for complex conditions that you intend for the game developer to be able to change.

Back in Ace, I had ended up using several procs as conditions for checking if some part of a script was enabled. This Boolean function allows you to essentially do the same, by allowing you to checking if the expression evaluates to true or not.

So what's the difference between this and eval? Well, probably not much, they both execute the given string as code. I'd like to think this is faster, but the honest truth is I haven't compared the speeds of it. If someone wants to build a small test to show the speeds, and eval proves to be faster, we can just as easily switch over to eval without breaking any code. I just ask to be able to run the tests myself so I can confirm on my own machines.

Now, since this does evaluate the string as code, this can pose a security risk, but really the whole game is a security risk. People can very easily get access to the developer tools in the game after you deploy the games, and that gives them direct access to run JavaScript commands in your game. So really, while it could potentially serve as a security risk, in most cases it's nothing worse than having the game available in general.

EDIT:


It looks like a lot of DataManager's functions are undefined. I noticed a lot of functions missing, so I tried just calling them in-game, and here's what I got in the console: 

DataManager.localContentPathundefined

DataManager.storageFileExists

undefined

DataManager.directoryExists

undefined

DataManager.removeDirectory

undefined

DataManager.storageSaveFile

undefined

DataManager.storageLoadFile

undefined

DataManager.storageRemoveFile

undefined

 
Hey, sorry to hear you were having trouble with these. The problem was another case of us being new to Git. These are functions I had worked on but had been forgetting to get uploaded to the git repo during development, and as such didn't make the cut into the original release. After a lengthy game of hide-and-seek on my computer looking for the right file, I've found them and added them to the repository. 

Thank you for the bug report!
 
Last edited by a moderator:

babykgar

Villager
Member
Joined
Oct 19, 2015
Messages
14
Reaction score
1
First Language
English
@Frozen dragon,

Thanks for replying!

Actually, I don't have any variables, right now :) . I've just been testing MVC functions in the console while reading through the plugin code. I'm new the community and to game code in general, so there's a lot that I'm figuring out right now as I go. With that said, please forgive my ignorance, and if you have the patience for it, please help me learn!  :D

The comment reads

Converts the string to a boolean. Any string except 'true' will return false

I saw "any string", entered the string "hello" (at one point, I entered "any string" XD) as the arg for MVC.Boolean(), and saw the error. With the code not doing what it said it was going to do, I felt I owed it to the creators to help out by reporting what I found. If my input is not helpful, feel free to tell me to stop, and I'll do that. Whenever I start submitting plugins, I hope my code gets all the scrutiny.

Anyway, here's the trace; the formatting is not ideal when I copied directly from the console, but I hope it's legible: 

MVC.Boolean(true)trueMVC.Boolean(false)falseMVC.Boolean("true")trueMVC.Boolean("false")falseMVC.Boolean("hello")undefined:1 Uncaught ReferenceError: hello is not defined message: "hello is not defined" stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Error undefined:1 (anonymous function) MVCommons.js:122 boolFunc VM229:2 (anonymous function) VM184:847 InjectedScript._evaluateOn VM184:780 InjectedScript._evaluateAndWrap VM184:646 InjectedScript.evaluateIf you're 100% sure that the arg is always always going to be a string of value "true" or "false", at least change the comment.
 
Last edited by a moderator:

babykgar

Villager
Member
Joined
Oct 19, 2015
Messages
14
Reaction score
1
First Language
English
@Zalerinian,

Whatever I can do to help, I'll be here.

I'm almost in the same boat concerning Git. I haven't gotten in the boat yet because I haven't started making a plugin and have never used Git, but I'll be suffering the same way soon enough  ;_;

I really appreciate what you all have done with this plugin. I'm excited to leverage it when I finally get started.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
934
First Language
English
Primarily Uses
N/A
@Frozen dragon,

Thanks for replying!

Actually, I don't have any variables, right now :) . I've just been testing MVC functions in the console while reading through the plugin code. I'm new the community and to game code in general, so there's a lot that I'm figuring out right now as I go. With that said, please forgive my ignorance, and if you have the patience for it, please help me learn!  :D

The comment reads

Converts the string to a boolean. Any string except 'true' will return false

I saw "any string", entered the string "hello" (at one point, I entered "any string" XD) as the arg for MVC.Boolean(), and saw the error. With the code not doing what it said it was going to do, I felt I owed it to the creators to help out by reporting what I found. If my input is not helpful, feel free to tell me to stop, and I'll do that. Whenever I start submitting plugins, I hope my code gets all the scrutiny.

Anyway, here's the trace; the formatting is not ideal when I copied directly from the console, but I hope it's legible: 

MVC.Boolean(true)trueMVC.Boolean(false)falseMVC.Boolean("true")trueMVC.Boolean("false")falseMVC.Boolean("hello")undefined:1 Uncaught ReferenceError: hello is not defined message: "hello is not defined" stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Error undefined:1 (anonymous function) MVCommons.js:122 boolFunc VM229:2 (anonymous function) VM184:847 InjectedScript._evaluateOn VM184:780 InjectedScript._evaluateAndWrap VM184:646 InjectedScript.evaluateIf you're 100% sure that the arg is always always going to be a string of value "true" or "false", at least change the comment.
Actually, I'm the one that made that function and Ramiro's description is slightly off. It doesn't interpret input as string, it interprets them as code, much like eval. That's why you're getting that error. It's trying to find the value of the variable 'hello', but there is no such variable, and all code inside the MVC module is set to throw an error if a variable has not been defined, but is used (this is set by the "use strict"; string at the very top of MVC's anonymous function).

The command will with with variables defined in a global scope, as the function has access to all global variables. For example,



Since the condition must result in a Boolean value (we use === which ensure the types are the same), the !! essentially casts it to a Boolean, because since SceneManager._scene is not null or undefined, it's technically considered true. !true is false, and !!true is also true. By using the double negative, we are guaranteed a Boolean value, however.

However, I am open to suggestions on this. I've considered making it only check technical value (by making it use == instead) so it'd return true as long as the expression's return value is not technically false (null, "", undefined, etc).

I'll update the description of the method now, but since it doesn't change any code, I won't be changing the version number on the plugin.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Every now and then I think about all the things I need in my project, and get overwhelmed. Just focus on your tilesets, me. You can't build your maps without 'em!
If a picture speaks 1000 words, how many pictures does a video speak??
I don't really get the "Pass Interference" Flag in (American) Football. Aren't you SUPPOSED to interfere with passes in Defense?? What exactly is the threshold that warrants a Flag?
TS Zeta.. blow your ass east... I cant take a round 3.
Trying to create a diagonal sprite, by following through GrandmaDeb's tutorial here.
(Basically, cutting up and resizing parts from the down and left version of the sprite.) :LZScheeze:


Forum statistics

Threads
104,431
Messages
1,006,311
Members
135,954
Latest member
peepoo
Top