Community Core Script

Discussion in 'Javascript/Plugin Support' started by Hudell, Oct 3, 2015.

  1. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    I just have no words...

    I mean, the insane notetag reading methods in yanflys core script is reason enough to NOT use those scripts (imo, and assuming you can write your own).
     
    #41
    AwesomeCool likes this.
  2. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    that was a rather rude response. My configuration options will be Javascript objects most notably json. I don't like note tags as options for scripts.
     
    Last edited by a moderator: Oct 19, 2015
    #42
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,816
    Likes Received:
    11,523
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If that isn't a case of the pot calling the kettle black ;) Your own scripts can be pretty complicated to wade through too. For a user, the method of reading note tags should be irrelevant. For a scripter, it should not interfere with your own methods for reading note tags, and is not a reason to avoid them - unless you are actually looking at modifying them yourself.

    Pot ... kettle ...


    Can you give some examples of your planned configuration options as JS objects? How would it look from the point of view of someone wanting to use your scripts in their game? Are you saying you're going to require users to actually edit the json files themselves to change configuration? That would be a step backwards imo, as MV has removed much of the error-factor that comes with non-scripters modifying scripts in order to customize them, and you would be reintroducing it.
     
    #43
  4. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    @Shaz - ok, that seems fair.. My own scripts can  be pretty complex to go through, no denying that. But complexity was not what I was highlighting, and I am certainly not trying to belittle yanflys work or anything of that nature..

    My main point, was that - after seeing Yanflys Core script (Mv Core) - the methods for reading notetags are EXTREMELY poorly written. (like, there is 4 insanely long methods - basically a js iteration of how he read notetags in ace - never mind the fact all notetags are already loaded at runtime via extractMetaData, and thus, rendered all 4 methods almost pointless...) And if something so simple as reading notetags is inefficient, I dread to think about the harder, more complicated  stuff and how many lines that would take...

    To me, when something as simple as reading the notetags from a database object cannot be done within a few lines, that raises the question of WHY. Why was that scripter not able to do that - was it cause they are too used to older methods (ie - hanging onto ace like coding styles), or was it the more worrying lack of knowledge of the new systems...

    I mean, yes, Yanfly has been writing code longer than I (both in general, and for mv), and thus, should* be more experienced / better than I. But length !== skill. And in this case (reading notetags) My way is much much more efficient. (at least imo.. I am sure there is others who would have issue with the way I do it, and that would make them avoid my work :D )

    Anyway, \rantover. ^_^
     
    #44
    AwesomeCool and Galenmereth like this.
  5. Galenmereth

    Galenmereth I thought what I'd do was Veteran

    Messages:
    2,206
    Likes Received:
    1,918
    Location:
    Norway
    First Language:
    English
    Primarily Uses:
    RMMV
    Personally I don't use MV's default notetag matching because I don't see the point in the bracket structure, and it's not really a good match for what I like to do. Here's how I match the notetag "icon_offset 8 12;" anywhere in the notetag box only once, case insensitive:

    TDDP_SuperSecretPlugin._findInEventNotetags(this, /icon_offset\s(.*?)\s(.*?);/i, function(result) { // Do things with the params if match is found, otherwise this isn't called this.SecretObj.customOffsetX = Number(result[1]); this.SecretObj.customOffsetY = Number(result[2]);});The _findInEventNotetags function prioritizes finding a match in an event's active page first before it looks in the Note box; my plugins generally view the Note box as "global" for said event, while notetags in comments as "local" to said page. The latter will override the former.
     
    Using the _findInEventNotetags function means that I cut down on "boilerplate" code later on when I check for lots of different notetags. No if/else chains or long case blocks while parsing the notetags whatsoever. The above code runs when an event changes its page, then stores the result in an object so as to not repeatedly call regexp functions (costly if it were to be done 60 times per frame).
     
    Last edited by a moderator: Oct 19, 2015
    #45
    ?????? likes this.
  6. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    I opted for a similar, yet somewhat different approach - using the default meta..

    Within my core plugin, I have this:

    (function($){  $.extractMetaData = function(object, metaid){    var meta = object.meta[metaid];    return meta !== undefined ? meta : null  };})(DMV);And then lets say I want to add a notetag into my custom script like this:

    <notetag: value>I can do so by aliasing the extractDataMethod to check my notetag when its checking everything else..

    (function(dm){ var extractMetadata = dm.extractMetadata; dm.extractMetadata = function(data) { extractMetadata.apply(this, arguments); data.myCustomNotetagValue = DMV.extractMetaData(data, 'notetag') };})(DataManager);which then stores the 'value' portion of the notetag into every single database item. Then, from an item - lets say an actor - I can easily check for the value of that notetag..

    this.actor().myCustomNotetagValue Annddd... Job done. :D

    By using this technique, I am able to store the data into my database objects like you, and also am not causing much harm to the system - cause all my logic is performed within loops that already occur, rather than creating my own and iterating over every line of a notetag all over again...

    I also have an extraction method for when notetags are expected to be split with some delimiter such as the ',' character.

    For my uses, there is not much need for anything else. :D

    Again, there is probably a better way to do it still, but this for me works perfectly, and doesnt require 4 methods just to read the note...
     
    Last edited by a moderator: Oct 19, 2015
    #46
    AwesomeCool likes this.
  7. Galenmereth

    Galenmereth I thought what I'd do was Veteran

    Messages:
    2,206
    Likes Received:
    1,918
    Location:
    Norway
    First Language:
    English
    Primarily Uses:
    RMMV
    That looks very sensible to me and I don't think you could optimize it further, really. I'd opt for the same approach when using database notetags. In my case I need to refresh notetags when an event changes its page, so I had to add some new functionality regardless :)
     
    #47
    ?????? likes this.
  8. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Yea, event pages are about the only thing that would require notes to be reread for each page, but even then, its not overly hard to refresh things when a page changes, so I dont think that would cause too heavy an impact on anything :D

    I cant wait till Mv is released and I can finally see what all you NDA'd people have been working on ^_^
     
    #48
  9. Yanfly

    Yanfly Developer

    Messages:
    1,696
    Likes Received:
    2,326
    I'll go ahead and shed some insight on why I choose to use my "poorly" written methods for notetagging over the inherent extractMetaData function.

    Frankly speaking, the extractMetaData function, while useful for the inexperienced scripter, is extremely un-userfriendly for the RPG Maker user (not the scripter). The meta data function requires the notetag to be case sensitive and the data stored later will also need to be extracted later. That's why using the method I use, I personally don't have to deal with that, plus I can give users the flexibility they need with non-case sensitive notetags. The work I've done for the notetags may look messy, but the extra work I put it is all for userfriendliness.

    As for this:

    (function(dm){var extractMetadata = dm.extractMetadata;dm.extractMetadata = function(data) {extractMetadata.apply(this, arguments);data.myCustomNotetagValue = DMV.extractMetaData(data, 'notetag')};})(DataManager);I've attempted to do that already. However, I've stumbled upon a couple problems:

    1. It's just raw data. It doesn't detect if it's from $dataItems, $dataWeapons, etc.
    2. It's doing it as it loads, which means, if I were to make a notetag that would copy or reference the properties of another object that would be loaded later, it wouldn't be able to do so.
    A brief history of my plugin creation process: I originally went with the extractMetaData function. However, because it wasn't doing what I wanted it to, I switched over to Scene_Boot, and realized that wasn't too effective a few weeks down the line. I eventually came to the conclusion that the best time to load and extract all the notetag data is during the time the entirity of the game's database is finished loading, which is where I got to for my plugin library today. Overall, I've made two major switches for the entirity of my notetags.

    That said, I'm open to criticism. There comes a problem in when doing something for a long time, programming styles can become stiff and uninnovative. That's why if you are to shed some light on where you can see my plugins can make an improvement, do share. Making a third switch for notetags isn't something I'm unwilling to do if I feel it's more beneficial.
     
    #49
    DoubleX, AwesomeCool, Zeriab and 7 others like this.
  10. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    I like to see people using the note box field for things like you know 

    <increaseStatX: 10%>, but I also like to see something like: 

    {increaseStatex: 10% } which is easier to parse and doesn't require regex. Now I don't have MV like Yanfly does so I don't know if that would be entirely possible.

    Now I like working with objects and json elements in javascript over strings and regex, so thats mostly how my scripts will be configured. For example:

    {  increaseStatx: 10%,  increaseStatY: {      whenHPIs: 5,      orWhenMPIs: 10,     by: 20%  }}This way you understand that we increase stat 10% and then we increase stat y by 20% when HP is 5 or when MP is 10. Its easy to read and you understand the logic of whats happening.

    Its also easy to parse. (The above would not be in a note tag. for note tags I would do: {enemyLevel: 5, seeConfig: "enemyName"} which would then know how to parse the core JSON config object looking for an enemy name with additional configuration options.)
     
    Last edited by a moderator: Oct 20, 2015
    #50
    Zeriab likes this.
  11. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    @Yanfly - Yes, of course the points you raise are fully valid. And I can understand why you have done things the way you have.. While I was looking over your functions I realized the flaws that lay within the default extract meta functionality - such as being case sensitive.

    One of my main 'concerns' would be that its not only your core doing that, its going to be every plugin that you write that uses notetags.  So with that in mind, would it not be more friendly - for you, and other people who stumble onto your code - to have I dunno, maybe one method to read any kind of notetag.. Then, just call that method a number of times to store the desired notetag values onto some variable?

    I dunno, just a thought... Ramiro came up with a VERY nice function to parse a string of text for some <tag> (case insensitive).. I shall message you about it. :)
     
    #51
  12. Yanfly

    Yanfly Developer

    Messages:
    1,696
    Likes Received:
    2,326
    In the case where there's one way to read notetags across all my plugins, it'd have to come out with a goto function that would decipher the data and then parse it.

    However, the notetags I use are structed based on userfriendliness and flexibility, something in which having a goto function would cause to be more difficult and tedious to proceed with. That said, should I even come up with the goto function, it'd be either included in a core script which everybody would need to download in order to use my plugins or included in all my plugins if I were to keep them separately and usable without the need of other plugins.

    I typically prefer stand-alone plugins so the first option is out of question, but if I proceed with the second option, it'd be easier to just extract the data straight from the notetags themselves. Also, I cannot speak for others, but I have a faster time reading RegExp in its raw form than if I had to read through various functions to determine what the notetag is supposed to be.
     
    #52
  13. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,069
    Location:
    Toronto
    First Language:
    English
    What happens if the chosen standard is unsuitable for certain cases? You'd have to live with it, or risk being alienated by the community because your note-tag does not conform to the rest of the project.


    I would rather scripters not assume anything about how the note-box is going to look and properly search for their own notes.
     
    #53
    AwesomeCool and Galenmereth like this.
  14. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,966
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Well, I will only use the default format, but in a case insensitive way.
     
    #54
    AwesomeCool likes this.
  15. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    You could always make your scripts work, but dont read the notetags unless the YEP_NoteCore.js (or whatever) is loaded - then, if available, you allow the script to alter various settings as per the notetags that have been set.   I mean, many systems can function perfectly without the use of notetags. :)

    And I dont think many people would mind adding a small note reading plugin to allow the notes from your systems to be read... Hell, in the past, most projects I have seen have at least 10+ of your scripts anyway :D

    I wasnt suggesting all script writers conform to using a single note loading function - although that would be ideal if the note parser can truly work with any kind of notetag - I was suggesting that for yanfly, he could include a note reading function that is used solely within his own plugins.

    Of course if someone requires notes to be read differently, it should be encouraged that they implement that to their hearts desire is fulfilled. But I also think that if someones code was not efficient in some way, it is all programmers duty to offer personal opinions and suggest improvements.

    Again, its also completely optional weather those suggestions are implemented, or even taken into consideration. :D
     
    Last edited by a moderator: Oct 20, 2015
    #55
  16. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    One of the things I find scriptors don't do is document there functions let alone document why they decided to alias something. I am glad that by documenting now you get to do a lot more in editor like setting values and what not.
     
    #56
    AwesomeCool likes this.
  17. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    923
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    The problem is that the notetag box is not very big, so it won't take long for a JSON formatted string to go out of the bounds of the box, requiring scrollbars. Additionally, this wouldn't work very well if other notes are in the notebox, because JSON.parse would encount an error with the other notetags, because they're not JSON, so finding your note specifically would be difficult/annoying to do. It would really be best to stick with the normal notetag format.
     
    #57
  18. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    it wouldn't go in the note box. :p Also no one said It was valid JSON, Welcome to javascript objects :D
     
    #58
  19. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,069
    Location:
    Toronto
    First Language:
    English
    How would you read javascript objects if they were stored in a text file or streamed from somewhere?
     
    #59
    Zalerinian likes this.
  20. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    Unfortunately for this you would have to go back to the old way of configuring scripts :( especially if you wanted the level of customization i want to offer, youd do it at the top of the script 

    var something = {   key: value}something.keyI realize we get to use comments and add customizability and then theres not tags for things like <bla: +10 > But the types of customizability wont work in those particular cases :(
     
    #60

Share This Page