Converting variable to notes

Discussion in 'Javascript/Plugin Support' started by silvestro673, Sep 22, 2016.

  1. silvestro673

    silvestro673 Veteran Veteran

    Messages:
    53
    Likes Received:
    3
    First Language:
    english
    Before someone thinks I'm wanting to simple display a variable in a text. Sorry to give you the wrong impression. I know to \V[x] to have a variable's value display in text.


    What I'm looking at is in the notes of actors and the rest, the plugins are usually <whatever: x>, a regular expression. In this example if x were 1000. Then the "whatever" command sequence turns its target to value 1000. I want to know how to make either <whatever: variableID> or <whatever: \V[x]> work.


    To my understanding, a reg expression searches strings for a specified match. So basically this <whatever: \V[x]> needs to have the \V[x] replaced with its value;   <whatever: 1000> all before the plugin is even read. Kinda reminds of the chicken or the egg story, which code line was read first?


    ~ my search for this answer's result mostly showed the \V[x] as the answer to a different problem. Hence, the opening comment. Ty for any answers.
     
    Last edited by a moderator: Sep 22, 2016
    #1
  2. mjshi

    mjshi Jack of Most Trades Veteran

    Messages:
    869
    Likes Received:
    695
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    N/A
    Could you clarify what you mean by "event plugin strings"? Do you mean the plugin command event function? That isn't regex (regular expressions), that reads what is typed in and checks to see if it exists as a function. That is, plugin writers can modify the plugin command method to accept a specific string to call a certain method. I won't go into specifics, but that's basically how it works.


    <whatever: variableId> will not work without additional coding to add support for what you want in the specific plugin that uses that notetag. The reason for this is that notes are read as strings and are NOT evaluated, rather, a variable is created that is set equal to the string that follows-- that is, item.meta.whatever (that's what the notes are converted to) will be set to "1".
     
    #2
  3. S_Rank_Crazy

    S_Rank_Crazy Veteran Veteran

    Messages:
    78
    Likes Received:
    47
    Location:
    The Other Batcave, UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Expanding on what mjshi said: the Notes section in the Database is stored on the object as a property (item.note), this property is a (long) string. For example:


    <whatever1: x>
    <whatever2: y>


    Is stored as:


    "<whatever1: x>\r\n<whatever2: y>"


    Plugin developers have to read that property and use regular expressions to retrieve the values of x and y for their plugin variables. I think the reason why we use that specific format is twofold:


    1) It gives users a familiar way to set up variables across different plugins


    2) When using regex, it helps to have a simple format to be able to extract the data you need


    So by default there's no way to do what you need. These settings are usually stored inside a plugin's namespace in the code, so you may be able to retrieve the value using a script call (if you know exactly where that plugin is stored). Other than that I'm not sure what to suggest.
     
    #3
  4. Ossra

    Ossra Formerly Exhydra Veteran

    Messages:
    646
    Likes Received:
    490
    First Language:
    English
    Primarily Uses:
    RMMV
    The core code of RPG Maker MV will convert any such note tags into meta properties automatically. Although plugin authors often process the raw tag data with regular expressions.

    Code:
    // Note Tag Field of Actor 4
    <foo:bar>
    
    // Note Tag Processed Meta Data
    $dataActors[4].meta.foo // returns 'bar'
    
    // Note Tag Raw Data
    $dataActors[4].note     // returns '<foo:bar>'
     
    #4
  5. S_Rank_Crazy

    S_Rank_Crazy Veteran Veteran

    Messages:
    78
    Likes Received:
    47
    Location:
    The Other Batcave, UK
    First Language:
    English
    Primarily Uses:
    RMMV


    You learn something new every day.
     
    #5
  6. Andar

    Andar Veteran Veteran

    Messages:
    27,712
    Likes Received:
    6,226
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @silvestro673


    an additional problem here is that the note itself has absolutely no function, it is the plugin that works through the data.


    And different plugin writer handle that differently.


    For example, some plugins process the notetag data on newgame and store it in their own datastructure, to never look at the notetags again. If that is not handled dynamically, nothing you do can change the values. So even if you manage to redirect the notetag to a variable (which is extremely difficult, see above), some plugins would still load the variable data from the game launch only (which will be zero in most cases) and never look again for any update inside that variable.
     
    #6
  7. silvestro673

    silvestro673 Veteran Veteran

    Messages:
    53
    Likes Received:
    3
    First Language:
    english
    Exhydra. I basically have no skill in regular expression creating so far. I'm willing to learn it, just don't want to lose focus off game development for now. (albiet - go hand in hand). I'm making it for my little guy and we enjoy our creating time together but he's too young to sit through coding lessons.


    Anyways, is there a way in common events > scripting to achieve this effect? the exact effect is only actor1 gets a bonus of jobpoints equal to the variable.


    example, on event, variable = variable + 500


    write to plugin text box (whatever the "gainJp actorId jp" name is),  "gainJp 1 " + "variable";


    then execute the plugin with the new text input.


    Whether the theory works or not, I'm hoping what i'm trying to do is not misunderstood.
     
    #7
  8. silvestro673

    silvestro673 Veteran Veteran

    Messages:
    53
    Likes Received:
    3
    First Language:
    english
    after some fiddling about, i didn't get the direct way i was asking for. but using a loop, i was able to achieve a successful result. 


    so i'm satisfied. this thread can be closed.
     
    #8

Share This Page