Clone Events

Discussion in 'JS Plugin Releases (RMMV)' started by Shaz, Jan 13, 2018.

  1. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Clone Events
    2018.01.13
    by Shaz

    Introduction
    This plugin allows you to copy events from a base map onto the current map. It is NOT an event spawning plugin - it replaces a 'placeholder' event on the current map with a 'source' event from the cloned map. All event content except location and id are replaced.

    How to use
    Add plugin to your js/plugins folder - name must be Shaz_CloneEvents.js
    Enable in plugin manager, and enter the map id where all the source events will be held into the plugin parameter.
    Create your source events on the clone map with all the event pages and content required. Give it a unique name (no two events on this map should have the same name - one will overwrite the other if that happens).
    Create your placeholder events on the game map. Put <clone:eventName> into the note box. eventName is the unique name of the event from the source map that you want to clone. This is the only thing you should do to the placeholder event.

    When playing the game, when the map is loaded, the source event will be copied from the clone map and placed at the placeholder event's location.

    Plugin
    Download from pastebin
    make sure to save it as Shaz_CloneEvents.js

    Credit
    - Shaz

    Terms
    - free for use in commercial games

    Notes
     
    Last edited: Jan 13, 2018
    #1
    Dreadshadow, Frogboy, kovak and 2 others like this.
  2. EpicFILE

    EpicFILE Epic Member Veteran

    Messages:
    295
    Likes Received:
    1,138
    Location:
    Bogor
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    Hello! I already tried this one out, but I can't really get it to work.
    I've created an original event and typed Snake in the name box.
    I put it on the base map. (set the base map ID as 6, because that's where I put the events)
    Tried to clone the event by typing <clone:Snake> on the notetags of new event.
    But I can't seem to get it to work.

    Is there something I'm missing?
    Thank you in advance! :D
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Did you save the plugin with the correct name?
    If you hit F8 and go to the console tab, are there any error messages?

    Could you please provide screenshots of your plugin manager, with this plugin selected, your event named Snake, and the event where you have <clone...> in the note box?
     
    #3
  4. EpicFILE

    EpicFILE Epic Member Veteran

    Messages:
    295
    Likes Received:
    1,138
    Location:
    Bogor
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    I'll put the screenshots inside the spoilers.

    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes, your plugin is not named correctly. The effect is that the game behaves as if it isn't even installed (and you got some errors in the console for the same reason).

    It must be called Shaz_CloneEvents.js as per the instructions in the first post.

    The pastebin page shows a more readable name, but unfortunately when you download, it gives it a slightly altered version of that name.

    To fix, delete the plugin from the plugin list, go to your plugin folder and rename the file, then add back to the plugin manager.
     
    #5
  6. EpicFILE

    EpicFILE Epic Member Veteran

    Messages:
    295
    Likes Received:
    1,138
    Location:
    Bogor
    First Language:
    Indonesia
    Primarily Uses:
    RMMV
    Thanks! Works like a charm.
    This is a very useful plugin to easily recreate complex, repeated events.
     
    #6
    Shaz likes this.
  7. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Like common events, but with event pages, conditions, and sprites :)
     
    #7
  8. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,182
    Likes Received:
    1,980
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Just noticed! Thank you squirrel for making this for MV <3
     
    #8
    Shaz likes this.
  9. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Hello!
    Its working great so far!
    But i want to know if there a way for me to activate the clone event via script call/ comment tag or plugin command, instead of using the notebox.
    because this will help me with a compatibility issue of another plugin who already use a notebox.

    So basicaly i want to when a switch is on, then the clone process will be active.

    Despite of this, its very simple and easy to use! Thanks!
     
    #9
  10. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    What about the event name? If you give the event the name
    Clone: SourceEvent

    then you could change these lines:
    Code:
            if ($dataMap.events[eventId].meta.clone) {
                this._clone = JsonEx.makeDeepCopy($dataClones[$dataMap.events[eventId].meta.clone]);
    

    to this:
    Code:
            if ($dataMap.events[eventId].name.match(/Clone: (\s*)/i) {
                this._clone = JsonEx.makeDeepCopy($dataClones[RegExp.$1]);
    and it will clone whatever event you put as SourceEvent. I think you'd have to make sure what you put as SourceEvent is the same case as the event on the clone map.

    I haven't tested this, so I might have the syntax wrong (specifically I'm not sure if the \s* part is correct), but I don't want to go to the trouble of testing it if you're going to say you don't want to use the event name.

    Using a script call, comment or plugin would be more difficult, because of the introduction of multiple pages and multiple event commands on each page.
     
    #10
    Eliaquim likes this.
  11. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Thank you Chaz! Didnt work either.
    No need to worry about, i will found some another way!
    Thanks!
     
    #11
  12. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Try \w* instead of \s* and make sure you have a space after the :

    edit ... here you go - change those lines to this:
    Code:
            if ($dataMap.events[eventId].name.match(/Clone:\s*([\w ]*)/i)) {
                this._clone = JsonEx.makeDeepCopy($dataClones[RegExp.$1]);
    I'm not a fan of regular expressions - takes so much experimenting to get them right.
     
    Last edited: Nov 12, 2018 at 5:14 PM
    #12
  13. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    Hi!
    It worked with the name of the event!
    But i cant do what i want either =/.
    But i'm sure not because your plugin, its the other. I think there's no way. Because the other plugin use an note tag in event for "connect" the event with the data of an enemie or a actor. So what i want its to bring other event from other map. But cloned events are link together with the names or notetag.
    I think the only way is have a way to only activate the clone with a switch, in ther page for example.
    But thats ok Chaz! This plugin i'm used its in development, so i guess i'm have to wait, be more patient.
    Thanks for your attention and effort anyway! I'm really apreciate that!
    PS: If you are curios, is this plugin: https://forums.rpgmakerweb.com/index.php?threads/tactics-system.97023/
     
    #13
  14. Shaz

    Shaz Veteran Veteran

    Messages:
    35,827
    Likes Received:
    10,121
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    @Eliaquim I think I know what's going on. When you clone an event, the event on the current map is a placeholder only, and is completely replaced by the cloned event. So if you have notetags, they are going to be removed.

    Put the notetag for the other plugin in the event on the clone map. (This also means it would have worked just as it was, without the change to use the event name). Then when it's cloned to the current map, it'll have the notetag for the other plugin.

    If it doesn't work then, try swapping the order of the two plugins.
     
    #14
  15. Eliaquim

    Eliaquim Veteran Veteran

    Messages:
    114
    Likes Received:
    17
    Location:
    Brazil - Rio de Janeiro
    First Language:
    Portuguese - Br
    Primarily Uses:
    RMMV
    I dont have time to try it yet. But as soon as i get some time, i will try! :D
     
    #15

Share This Page