An open library of RPG Maker MV plugins, powered by the community.

PGMV - The Community-Driven Plugin Library for RPG Maker MV

MV plugins

Template Event - TemplateEvent.js

Plugin desc : Template Event Plugin

License : MIT License

Author : Triacontane

Website : https://triacontane.blogspot.com/

Download Page : https://raw.githubusercontent.com/munokura/triacontane-MV-plugins/refs/heads/main/TemplateEvent.js

File name : TemplateEvent.js

Help of plugin :

@plugindesc Template Event Plugin
@author triacontane

@help
English Help Translator: munokura
This is an unofficial English translation of the plugin help,
created to support global RPG Maker users.
Feedback is welcome to improve translation quality
(see: https://github.com/munokura/triacontane-MV-plugins ).
Original plugin by Triacontane.
Please check the latest official version at:
https://triacontane.blogspot.com
-----
TemplateEvent.js[Template Event Plugin]

You can template commonly used events.
Please define the template event in the map prepared exclusively.
Just by writing a predetermined description in the note of the actual
event, It can be replaced dynamically.

You can also call up the source event from the template event.
It is effective when you want to do some unique processing,
such as treasure boxes and place movement events.
Describe the appearance and event processing of the common part
in the template event,
We describe only the unique part such as item acquisition and
location destination designation in the original event.

It also provides a function to call an arbitrary map event like a common
event.
Events to be called can be specified by ID and event name.

Procedure
1.Create a template map and place a template event.

2.Write a Note field of the event you want to replace
with the template event. Both ID and event name can be specified.
<TE:1>
It is replaced with the event of ID [1] of the template map.

<TE:aaa>
It is replaced with the event of event name [aaa] of the template map.

<TE:¥v[1]>
It is replaced with the event of ID of template map [value of variable
 [1]].

In principle, all settings except initial placement will be replaced with
template event settings If you specify graphics as an exception and when you
write a Note field (* 1)
Priority is given to the settings of unique events for the following settings.
Image
Autonomous Movement
Options
Priority
Trigger

*1 Write it in the Note field of the unique event as follows.
<TEOverRide>

- Self Variable Function
You can define self variables (variables specific to that event) for
events.
You can use these variables from plugin commands to display text or as
event conditions.

When used in "Text Display" mode
You can display them using the control character "¥sv[n](n:index)."

When used in "Event Conditions" mode
Start the event command on the target page with "Annotation"
and specify conditions using the following format. Multiple conditions can
be specified.

¥TE{condition}

Conditions are written in JavaScript and control characters are allowed.
Example:
¥TE{¥sv[1] >= 3} # If self variable [1] is 3 or greater
¥TE{¥sv[2] === ¥v[1]} # If self variable [2] is equal to variable [1]
¥TE{¥sv[3] === 'AAA'} # If self variable [3] is equal to 'AAA'

When used in scripts such as "conditional branching"
The following script retrieves the self variable at the specified index.
this.getSelfVariable(n)
Example:
this.getSelfVariable(1) !== 0 # If self variable [1] is not 0

Plugin Command
Execute from the event command "Plugin Command".
(Separate parameters with a space.)

TE_CALL_ORIGIN_EVENT [PageIndex]
 Call up the event processing of the replacement source.
 After processing is completed, it returns to the original processing.
 If you omit the page number, the running page number is applied as it is.
 It is effective only when described in the template event.

 ex
 TE_CALL_ORIGIN_EVENT 1

TE_CALL_MAP_EVENT [EventId] [PageIndex]
 Call up another event processing in the same map.
 After processing is completed, it returns to the original processing.
 If you specify an event  ID other than a numeric value,
 it calls processing of an event that is treated as an event name and
 whose event name matches.
 It is valid even if it is described in the template event.

Example 1: Call the first page of events with ID [5].
 TE_CALL_MAP_EVENT 5 1

Example 2: Call the first page of events named [aaa].
 TE_CALL_MAP_EVENT aaa 1

TE_SET_SELF_VARIABLE [Index] [Operation Type] [Operand]
Operates on a self variable.
Index: The index of the self variable to operate on. Specify a number
greater than or equal to 1.
Operation Type: The operation type. Specify one of the following:
0: Assign
1: Add
2: Subtract
3: Multiply
4: Divide
5: Remainder
Operand: The setting value. Specify a number.
*If you want to set a non-numeric value to a self variable, specify it in
a script.

Example 1: Assign the value [100] to the self variable with index [1].
TE_SET_SELF_VARIABLE 1 0 100

Example 2: Subtract the value [50] from the self variable with index [3].
TE_SET_SELF_VARIABLE 3 2 50

Example 3: Add the value [value of self variable [1]] to the self variable
at index [5].
TE_SET_SELF_VARIABLE 5 1 ¥sv[1]

TE_SET_RANGE_SELF_VARIABLE [Start INDEX] [End INDEX] [Operation Type] [Operand]
Operates self variables in bulk.

The control character ¥sv[n] can be used in all plugin commands of this
plugin.

・Script (executed from event command scripts or variable operations)
Gets the template event ID and name during a specific process call.
this.character(0).getTemplateId();
this.character(0).getTemplateName();

Gets the self variable at the specified index.
this.getSelfVariable(index);

Sets a value to a self variable.
This script can also be executed in "Set Movement Route."
Setting formulaFlg to true evaluates the operand as a formula.
this.controlSelfVariable(index, type, operand, formulaFlg);

Sets values ​​to self variables in bulk.
This script can also be executed using "Setting the Movement Route."
this.controlSelfVariableRange(start, end, type, operand, formulaFlg);

Controls the self-variable of an external event.
$gameSelfSwitches.setVariableValue([Map ID, Event ID, INDEX], Set Value);

Gets the self-variable of an external event.
$gameSelfSwitches.getVariableValue([Map ID, Event ID, INDEX]);

When using with SAN_MapGenerator.js
Define this plugin below SAN_MapGenerator.js.

Terms of Use:
You may modify and redistribute this plugin without permission from the
author, and there are no restrictions on its use (commercial, 18+, etc.).
This plugin is now yours.

@param TemplateMapId
@desc The map ID where the template event resides.
@default 1
@type number

@param KeepEventId
@desc Maintain the event ID of the caller when invoking the map event.
@default false
@type boolean

@param OverrideTarget
@desc Overwrite in the Note field (priority is given to the settings of specific events over template events) Set the items to be overwritten for the specified event.
@default {"Image":"true","Direction":"false","Move":"false","Priority":"false","Trigger":"false","Option":"false"}
@type struct<override>

@param AutoOverride
@desc The settings in the "Items to be overwritten" will be overwritten even if you do not set an overwrite in the Note field.
@default false
@type boolean

@param IntegrateNote
@desc Combines or overwrites the Note fields for template events and unique events.
@default 0
@type select
@option None
@value 0
@option Integrate
@value 1
@option Override
@value 2

スポンサードリンク

-MV plugins

Copyright© PGMV - The Community-Driven Plugin Library for RPG Maker MV , 2026 All Rights Reserved.