Clone Events

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
Clone Events v1.0
Shaz
Introduction
When you have heaps of events that are all exactly the same, and then you decide you want to make one small change, finding every single event and repeating that change can be a nightmare. This script will let you create an event once, and then clone it to any other map. If you decide you want to change something, you change one event on one map. That’s it.

How to Use
Paste into a new script slot below Materials. If there are conflicts with other scripts that alias the Game_Event.initialize method, place this script above those.

Set Your Preferences
CLONE_MAP - set this to nil if you want to copy events from any map, or to the map id (no leading zeros) if you want to keep all your source events on a single map.
USE_NAME - set this to true if you want to name your source events (all source events on the same map must have unique names), or to false if you want to refer to events via their ids (no leading zeros).

Create Your Source Events
Create the events to be copied just like you'd create any regular event. If CLONE_MAP is set to a map number, all of these source events should be on that map. If USE_NAME is set to true, all of the source events on a single map should have unique names

Create your Clones
On the map the player will visit, create a 'dummy' event (you can name it if you want, but you don't have to; you can also give it an event graphic if you want, which will help you identify/locate it later should the need arise).
This dummy event will have a single event page, with one event command - a comment.

If you are cloning events from any map (CLONE_MAP = nil) and using event names (USE_NAME = true),
Code:
<clone mapid eventname>
<clone 18 ogre>
If you are cloning events from any map (CLONE_MAP = nil) and using event ids (USE_NAME = false),
Code:
<clone mapid eventid>
<clone 18 7>
If all your source events are on the same map (CLONE_MAP = 18 or other map id) and you are using event names (USE_NAME = true),
Code:
<clone eventname>
<clone ogre>
If all your source events are on the same map (CLONE_MAP = 18 or other map id) and you are using event ids (USE_NAME = false),
Code:
<clone eventid>
<clone 7>
Script
Get it here


Credit and Thanks
- Shaz

Author's Notes
Free for use in commercial games. Give credit.

In response to erthia's request, I have converted this script for use in VX.
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,111
Reaction score
11,459
First Language
English
Primarily Uses
RMVXA
Thank you for this.  I know it would have saved me hours (and hours and hours and...) in the past, so great to have it for the future.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,237
Reaction score
1,329
First Language
English
Primarily Uses
RMXP
Good work shaz :D

It's a nice and well-executed idea.

One small question. Why require at least one whitespace character after clone?

*hugs*
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
Purely for readability.


It would be a small thing to change to allow the words/numbers to run-on. Do you suggest it would be better to add that flexibility?
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,237
Reaction score
1,329
First Language
English
Primarily Uses
RMXP
Consider what happens if a user accidentally does not add a space. What is the consequence? How obvious is the error?

Also, what would happen we relaxed the patterns of the double values like this?

  PATT_MAP_NAME = /<clone\s*(\d+)\s*(\w+)>/i  PATT_MAP_ID = /<clone\s*(\d+)\s*(\d+)>/i
*hugs*
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
The first one would work, unless the event name began with a digit. The second would not work at all :)


Is <clone 1825> meant to clone event 825 from map 1, 25 from map 18, or 5 from map 182?


So I would force the space between map id and event id/name in both cases.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,237
Reaction score
1,329
First Language
English
Primarily Uses
RMXP
Not work at all? Just because it's counter intuitive doesn't mean it wouldn't work. What would <clone 1825> for example yield? Also what about the first case if we have this instead?

Code:
  PATT_MAP_NAME = /<clone\s*(\d+?)\s*(\w+?)>/i
 
Anyway, yes, you are correct. Using whitespace to distinguish between the two values is definitely a good idea:
Code:
  PATT_MAP_NAME = /<clone\s*(\d+)\s+(\w+)>/i  PATT_MAP_ID = /<clone\s*(\d+)\s+(\d+)>/i
Disregarding the allowed ugliness. How do feel about this? Try considering the pros and cons of this. Should we give more flexibility to reduce readability?

Could there be other potential issues or interesting aspects?

*hugs*
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
Haha - why do I get the feeling you're testing me?


I say wouldn't work, but I really mean it could be ambiguous, so it's better to not allow the situation. 1825 could mean one event on each of three different maps. I COULD make the script check to see if each map exists (there's something I didn't do), and if the event exists on that map. If there is only one combination that actually works, use it. But what if there's more than one? The script cannot decide which one the user meant, and it would be wrong to just pick one. So it's better to force them to separate the map id and event id.

Also what about the first case if we have this instead?

  PATT_MAP_NAME = /<clone\s*(\d+?)\s*(\w+?)>/i
This is where we test my understanding of regular expressions and find it severely lacking (another reason I like to keep them simple).


(\d+?) is allowing them to leave out the map id, but that pattern would only be used if the constants were set to indicate that a map id would be provided. So while I could allow it, it would result in either the $1 and $2 being mixed up (would \d+? but being left out make $1 nil, and would that translate to 0 as the map id, or would it put \w+? into $1 instead) - in both cases it would lead to trying to load a map that didn't exist, or the wrong map. I would prefer to force the user to stick with the format they said they were going to use (and provide the map id), than to have it crash because it can't load that map. Or it may result in the pattern not matching, and the event not being cloned. Less drastic than a crash, but still not the desired outcome. It would not take much for me to test and see which of those situations would actually happen, but none of them would be desirable.


I personally would prefer to use the space to delimit, and in this case, yes, I'm forcing that preference on users of the script, but I'm not against making things flexible for others to use their own preferred formats. Along those lines, it would be even nicer if I allow ANY non-numeric/non-character delimiter to be used, and not just whitespace. Until it reaches a point where I'm spending too much time figuring out all the possibilities and getting my expression to cater for them all. I write my scripts to use in my own game, and I share them if I think they'll be useful to others. If I answer someone's script request, I'll usually ask them how they would like to use it, and will design the script around that information. Usually I won't attempt to make my scripts more flexible than my own requirements dictate just because of the time required to do it. With this script, I did (I added the ability to use event number OR name, and to allow events to come from any map rather than a single one), because it made sense to do that, and I'd expect most people to NOT want to use it the same way I am. But I also added the flexibility because it wasn't hard to add and I could do it quickly.


So if it's going to take a lot of mucking around and testing to make it more flexible, I'm okay with restricting how it can be used, knowing if someone really wants to do it differently, they can change the script themselves, or make a request to have it changed :)
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,237
Reaction score
1,329
First Language
English
Primarily Uses
RMXP
I am teaching :D


1825 is matched in one particular way. I suggest you look up the section on greedy/non-greedy operators in my tutorial.


Writing that tutorial really help me understand regular expressions, so maybe you can do a tutorial on the matter. Mine pretty much only focuses on creating the regular expressions. A tutorial on the application of your defined regular expressions can definitely be useful. (I am too lazy to make it myself)

This is where we test my understanding of regular expressions and find it severely lacking (another reason I like to keep them simple).
Even simple regular expressions can contain gotchas.

(\d+?) is allowing them to leave out the map id, but that pattern would only be used if the constants were set to indicate that a map id would be provided. So while I could allow it, it would result in either the $1 and $2 being mixed up (would \d+? but being left out make $1 nil, and would that translate to 0 as the map id, or would it put \w+? into $1 instead) - in both cases it would lead to trying to load a map that didn't exist, or the wrong map. I would prefer to force the user to stick with the format they said they were going to use (and provide the map id), than to have it crash because it can't load that map. Or it may result in the pattern not matching, and the event not being cloned. Less drastic than a crash, but still not the desired outcome. It would not take much for me to test and see which of those situations would actually happen, but none of them would be desirable.
Is that really what would happen? Try it out. Create a project and play around with regular expressions.
You are somewhat right. If they user forgets to add a space there will be no match so cloning will not happen for that event. The issue should be immediately obvious when they test the current working area. About relaxing the rules to allow more than just whitespace as separators. What’s the difference between \w and \W?


I prefer your solution to allowing no whitespaces. It educates the user in a nice manner. Moreover it decreases possible conflicts. What if I had a script that used <clone_common_event 42>, <clone_bat> or some other different functionality which had <clone\w as the prefix.


It is fun teaching you again >:3


*hugs*


- Zeriab
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
bah, teaching, torturing, what's the difference, as long as you're having fun doing it ;)


Very well, I shall submit to your torments, and reveal my findings.
 

Richard John S

Rpg Maker Music Pack Contributor
Veteran
Joined
Jan 31, 2014
Messages
186
Reaction score
694
First Language
English
Primarily Uses
RMMV
Hey Shaz!!! Great work. I tested it with ace and it is everything I need for my project, Legend of Erthia, and it would save a lot of work in regards to eventing. Is it possible to get a quick VX version to this? I tried converting it myself but... there are some parts of coding I just can't tackle.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
I'll see if I can do it in the next few days. Bump this post to remind me if it's not done by Monday.
 

Richard John S

Rpg Maker Music Pack Contributor
Veteran
Joined
Jan 31, 2014
Messages
186
Reaction score
694
First Language
English
Primarily Uses
RMMV
Thanks a lot Shaz, greatly appreciated.

I'll see if I can do it in the next few days. Bump this post to remind me if it's not done by Monday.
 

Halrawk

Veteran
Veteran
Joined
Dec 14, 2012
Messages
97
Reaction score
24
First Language
English
Primarily Uses
This will help me out tonnes! I keep all my enemies in the same map, and just call them using other scripts, but your script will save me a lot of time and effort, thanks!

Not at home at the moment, so I can't test it, but just to confirm, this clones the entire event, including move patterns, graphics, etc, right?
 
Last edited by a moderator:

ShadowFox

Adventurer
Member
Joined
Mar 13, 2012
Messages
255
Reaction score
10
First Language
English
Primarily Uses
Have a question dealing with this script. What if the clone events are to have different sprites, but the contents are the same?

EG: 20 to 20 NPC's that say a random number of things, up to say 50 random things, per town?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
@Halrawk, yes, it clones the entire event.


@ShadowFox, no, it clones the entire event - graphics and all. You would need to do a mod if you wanted it to use a sprite based on the event it's copying TO. And have that mod take into account how many pages the cloned event might have, and how to tell which of those require the sprite and which don't.
 

ShadowFox

Adventurer
Member
Joined
Mar 13, 2012
Messages
255
Reaction score
10
First Language
English
Primarily Uses
no, it clones the entire event - graphics and all. You would need to do a mod if you wanted it to use a sprite based on the event it's copying TO. And have that mod take into account how many pages the cloned event might have, and how to tell which of those require the sprite and which don't.
Sorry for the noob question, but as I'm not a scripter I have no idea what you mean by mod?

Do you mean put in another script or what?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,639
Reaction score
13,245
First Language
English
Primarily Uses
RMMV
Not another script, but a change to the script above to add your extra requirement to preserve the sprite instead of copying it from the "source" event.


in this case, mod = modification
 

Richard John S

Rpg Maker Music Pack Contributor
Veteran
Joined
Jan 31, 2014
Messages
186
Reaction score
694
First Language
English
Primarily Uses
RMMV
Hey Shaz, just bumping the post as requested. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

What is your favourite rpg maker plugin?
Hopefully this gets fixed before release..
Where's this sudden heatwave come from? It's not even sunny, it's just hot. Hate it!
I'm slightly disappointed that the MZ codebase still uses core.js, managers.js, objects.js, scenes.js, sprites.js and windows.js instead of core/Bitmap.js, core/Graphics.js, managers/AudioManager.js, managers/DataManager.js, etc...
just a few more hours until the toughest, most pressure 72 hours of my life, wish me luck guys

Forum statistics

Threads
100,565
Messages
977,269
Members
132,148
Latest member
jcamp10565
Top