Better plugin param values storage

Discussion in 'Editor Suggestions and Improvement' started by ICF-Soft, Aug 10, 2017.

?

Would you like this feature?

  1. Yes

    1 vote(s)
    20.0%
  2. No

    1 vote(s)
    20.0%
  3. Yes but not important

    3 vote(s)
    60.0%
  1. ICF-Soft

    ICF-Soft Veteran Veteran

    Messages:
    209
    Likes Received:
    99
    First Language:
    Spanish
    Description of the Feature:
    Recently new plugin param types have been added.
    Even all these new param types there are all stored as strings. Numbers, booleans, notes, arrays, etc need to be converted througth functions like JSON.parse().
    When parsing arrays and structures their contents become strings no matter the content type and need also to be converted. Something anoying when you want to add complex data like three dimensional number arrays, quests arrays, and so on.

    Code for Implementation:
    Somehow it actually adds quotes to convert data into strings. If these quotes aren't added for those params that don't need them plugin params will be saved properly like data are.

    Why is this feature good?
    This feature is great because of the following:
    • Avoiding to use JSON.parse function on every param.
    • Coding becomes easier.
    • Reduces startup time.

    Possible issues with this feature?
    Issues that might arise from this feature:
    • If not treated properly it could give issues with the non-string params that were saved as strings.
     
    #1
    LTN Games likes this.
  2. LTN Games

    LTN Games Veteran Veteran

    Messages:
    644
    Likes Received:
    499
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I voted yes but not important. Not because I don't like the idea of a better storage for param values but because it's solved rather easily with a simple function. And because the reason they are strings is because of backwards compatibility. That being said, I am still all for a better storage system, but backwards compatibility needs to be thought about during the process.
    It would be nice to see the default file for parameters "plugins.js" (for backwards compatibility) but also a new file created by the editor which can be used by plugin devs who don't want to convert all those dang strings lol, preferably parameters.json which is simply called using a function like PluginManager.getAllParameters(), which will return a proper JSON array of objects from all plugins in the plugin manager.
     
    #2
  3. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    527
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I spoke with a dev from the RMMV OSS Project why the new parameters are setup how they are. They need to be strings because of backwards compatability, so they cannot and will not change that.
    But as @LTN Games suggested, they could implement a second plugin parameter file.
    I also voted "yes but not important" because you can just write your own function that will parse the parameters into the right types, because I think there might be more important issues to do.

    PHP:
    var JSONSuperParse = function (string) {
       var 
    temp;
       try {
           
    temp JsonEx.parse(string);
       } catch (
    e) {
           return 
    string;
       }
       if (
    typeof temp === 'object') {
           
    Object.keys(temp).forEach(function (key) {
               
    temp[key] = JSONSuperParse(temp[key]);
               if (
    temp[key] === '') {
                   
    temp[key] = null;
               }
           });
       }
       return 
    temp;
    };
    This function will return an object with the right types for all parameters.
     
    Last edited: Oct 8, 2017
    #3
    ICF-Soft and LTN Games like this.
  4. ICF-Soft

    ICF-Soft Veteran Veteran

    Messages:
    209
    Likes Received:
    99
    First Language:
    Spanish
    Well. It's a pity that parameters need to be continuously parsed for each inner key. I was affraid of getting a "max stack call exceed" error when using recursion functions but if there isn't any other way.
    If parameters need an only parsing it would be enough and will not affect backward compatibility.
     
    #4
  5. Fornoreason1000

    Fornoreason1000 Black Sheep Veteran

    Messages:
    200
    Likes Received:
    92
    Location:
    Anor Londo
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes but not important

    persontally i wouldnt use Plugin parameters to store something crazy like a 3 dimensional array , Json.parse is the least of your problems if your editing that thing in that tiny little box. once things get that complex you kinda need to look at making a data file or something. this would actually solve your problem entirely.
    JSON is pretty easy to read and write in anyway.

    Code:
    [{name: "Its more lilkey than you think", stages [
    {id: 1, desc: "something is killing Delphines Rats", journal: "The Fighter guild Porter is entirelyy useless , so i'd better jsut head straight to delphines houses"},
    {id: 34, desc: "Atrtack by Mountian lion", journal: "I was attacked by a mountain Lion, i better report to delphine"}], rewardItems: [[1,3], [2,3],[40,1]},
    
    {name: "City Escape", stages: [{desc: "Help Sonic Escape that really really fast truck"}], rewardArmour: [[2,2],[4,2]], rewardGold: 200},
    
    {name: "Cloud 9", stages: [{id: 1, desc: "Tifa was seen on a wierd boat, Aerith has a plan to help find her"}], rewardWeapon: [[4,1]]},
    
    {name: "Bells of awakening", stages: [{id: 4, desc: "I am a giant Snake!},
    {id: 9, desc: "Chaos Witch defeated, now for the gargoyles"},
    {id: 10, desc: "Gargoyles have been slain, now for the Fire Weilding Witch!"},
    {id: 15, desc: "Both Bells have been run, something has happned! Better check it out"},
    {id: 20, desc: "The Basilisk that emrged turn out to be freindly, with that he will instruct me on further task"},
    ], rewardItem:[[9,1]], rewardGold: 90000}
    
    etc
    ]
     
    Last edited: Sep 8, 2017
    #5
  6. ICF-Soft

    ICF-Soft Veteran Veteran

    Messages:
    209
    Likes Received:
    99
    First Language:
    Spanish
    Well. You can't force others to learn JSON, and the need of extra utilities could be something tedious.
    DataActors is stored as an object that doesn't need any parsing while plugin parameters need recursive parsing on complex ones.
    The features that came with 1.5.0 will make that a lot of plugins use complex parameters. You'll see later or sooner.
     
    #6
  7. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    527
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I think for beginners it is easier to deal with Plugin Parameters even if they get a bit more complex than do deal with the equivalent complex structure in a JSON file. Because they would need to learn JSON.
    I see a lot of people struggle with JSON files. If you are not used to coding it seems it is a bit hard to get into it.
     
    #7
  8. Fornoreason1000

    Fornoreason1000 Black Sheep Veteran

    Messages:
    200
    Likes Received:
    92
    Location:
    Anor Londo
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't want to force others to use JSON at all,
    i was just completely ignorant of the plugin managers new plugin parameter system, which wasn't updated in the help file at all. i was under the impression that when the OP said "3 dimentional Arrays/Quest" and "JSON.parse" they were typing up 3 dimentional arrays in JSON in the old style text box :aswt:

    fortunately i found this...
    https://forums.rpgmakerweb.com/inde...w-plugin-manager-in-rpg-maker-mv-1-5-0.79764/

    plugins parameters are still stored as JSON file, they arent encoded in some format where it can directly deserialize into say an integer. before this update were were parsing everything from a string. but considering how much data can now be entered this way more easily.

    Code:
    {"name":"DSE-Test","status":true,
    "description":"Test",
    "parameters":{"3 Dimentional Array":"[[[1,2,3],[2,4,6]],[[7,8,9],[10,11,12]]]"}} //this will bascally always require a Json conversion of some kind
    
     
    #8

Share This Page