MVCommons - The community core plugin

Discussion in 'JS Plugin Releases (RMMV)' started by Zalerinian, Oct 24, 2015.

  1. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    924
    Location:
    The Internet.
    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: Dec 5, 2015
    #1
  2. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    924
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    Last edited by a moderator: Dec 5, 2015
    #2
    kangtaw likes this.
  3. tati light

    tati light Veteran Veteran

    Messages:
    160
    Likes Received:
    109
    First Language:
    English
    Thanks very much for this! I greatly appreciate this. Once I learn about Javascript, I will try to help as well.
     
    #3
    Hudell likes this.
  4. JosephSeraph

    JosephSeraph White Mage Restaff

    Messages:
    881
    Likes Received:
    736
    Location:
    Santos, Brasil
    First Language:
    Portuguese
    How far we've come! And yesterday we were using SephirothSpawn's SDK!
     
    #4
    Rogue Milk likes this.
  5. Ramiro

    Ramiro Now with an army of Mecha-Ralphs! Veteran

    Messages:
    860
    Likes Received:
    366
    Location:
    Argentina
    First Language:
    Spanish
    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...
     
    #5
  6. JosephSeraph

    JosephSeraph White Mage Restaff

    Messages:
    881
    Likes Received:
    736
    Location:
    Santos, Brasil
    First Language:
    Portuguese
    ...That's exactly the point of my commentary?
     
    #6
  7. Seriel

    Seriel Veteran Member

    Messages:
    3,018
    Likes Received:
    508
    Location:
    Wales, UK
    First Language:
    English
    Primarily Uses:
    Other
    I believe JosephSeraph meant this is better than the old SDK and that we've moved on.

    Right?
     
    #7
  8. JosephSeraph

    JosephSeraph White Mage Restaff

    Messages:
    881
    Likes Received:
    736
    Location:
    Santos, Brasil
    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!
     
    #8
    Seriel likes this.
  9. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    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: Oct 25, 2015
    #9
  10. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,969
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    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);};
     
    #10
    estriole likes this.
  11. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    First Language:
    indonesian
    somehow it throw

    reference error...

    object is not defined...

    i install the MVCommon plugin above my plugin...
     
    #11
    Zalerinian likes this.
  12. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    924
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    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.
     
    #12
  13. estriole

    estriole Veteran Veteran

    Messages:
    1,030
    Likes Received:
    334
    First Language:
    indonesian
    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...
     
    #13
  14. babykgar

    babykgar Villager Member

    Messages:
    14
    Likes Received:
    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: Oct 25, 2015
    #14
  15. babykgar

    babykgar Villager Member

    Messages:
    14
    Likes Received:
    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
     
    #15
    Zalerinian likes this.
  16. Ramiro

    Ramiro Now with an army of Mecha-Ralphs! Veteran

    Messages:
    860
    Likes Received:
    366
    Location:
    Argentina
    First Language:
    Spanish
    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: Oct 25, 2015
    #16
  17. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    924
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    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:


    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: Oct 25, 2015
    #17
  18. babykgar

    babykgar Villager Member

    Messages:
    14
    Likes Received:
    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: Oct 25, 2015
    #18
  19. babykgar

    babykgar Villager Member

    Messages:
    14
    Likes Received:
    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.
     
    #19
  20. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    924
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    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,

    [​IMG]

    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.
     
    #20
    babykgar likes this.

Share This Page