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

PGMZ - The Community-Driven Plugin Library for RPG Maker MZ

MZ plugins

Self Variable - SelfVariable.js

Plugin desc : Self variable v1.5.1

License : MIT License

Author : unagiootoro

Website : https://github.com/unagiootoro/RPGMZ/blob/master/SelfVariable.js

Desc page : https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/SelfVariable.js

Download Page : https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/SelfVariable.js

File name : SelfVariable.js

Help of plugin :

@target MV MZ
@plugindesc Self variable v1.5.1
@author unagiootoro
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/SelfVariable.js
@help
A plugin that introduces self variables.

【How to use】
■ Basic usage
If you prefix the variable name with "$", the variable is treated as a self variable.
Setting example: $ Self variable

self variables are managed on an event-by-event basis, similar to self switching.
You can get and set the value of a self variable on the editor in the same way as a normal variable.
You can do it.

In addition to variables, switches can also be treated as extended self switches by adding "$"
to the beginning of the switch name.

■ Using common event variables
A variable name prefixed with "%" will be treated as a common event variable.
Setting example: %Common event variable

Common event variables are variables that can only be used within common events.
The value is initialized to 0 to call common events.
If you call a common event within a common event,
Values are not shared between common events.

■ Using Decimal Variables
Prefixing a variable name with "#" treats it as a decimal variable.
Setting example: # decimal variable

A variable set to a decimal variable retains its value as a decimal even if a decimal value is assigned to it.
For the setting of the decimal, in "Variable operation" of the event command,
This can be done by entering a decimal value in the script field.

Also, if a description such as "#$" is attached to the beginning, the variable is treated as a self variable and a decimal variable.
can be handled. Either "#" or "$" can be written first.
Setting example: #$ decimal self variable

■ Manipulate self variables from plug-in commands
"Get self variable value" and "Set self variable value" of the plug-in command
By using self variables from one event to another
It is also possible to operate.

Similarly for the extended self switch, you can operate the extended self switch from the outside
by using "extended self switch value acquisition" and "extended self switch setting".

Plugin commands can only be used when running on MZ.
In the case of MV, by using the function to operate self variables from the script
The same can be achieved.

When specifying "map ID" in the plug-in command, "map ID"
If 0 is specified, the ID of the current map is applied.
Also, if 0 is specified for "Event ID" when specifying "Event ID",
The ID of the event that executed the plugin command is applied.

When clearing the self variable/extended self switch with the plugin command,
if the argument "whether event is specified" is ON,
the event specified by the event ID or variable will be cleared. When set to OFF,
all events on the map will be cleared.

■ Batch setting of self variables/extended self switches using event tags
If you set an event tag to an event, the plug-in command "Set self variable value by event tag" will be displayed.
Or with the event tag specified by "Extended self switch value setting by event tag"
Self variables or extended self switches can be set for all events.
Multiple event tags can be set.
When setting an event tag, please describe it as follows in the first annotation of page 0 of the event.
<et: event tag>

Example: When setting event tags "ET1" and "ET2"
<et: ET1>
<et: ET2>

■ Manipulate self variables from scripts
・Acquisition of self variables
Example: To get the self variable of ID3 of the map of ID1 and the event of ID2
$gameVariables.selfVariableValue([1, 2, 3]);

・Self variable setting
Example: If you want to set the self variable for ID3 to 100 for the event for ID2 in the map for ID1.
$gameVariables.selfVariableValue([1, 2, 3], 100);

・Acquisition of extended self switch
Example: To get ID3's extended self switch for ID2's event of ID1's map
$gameSwitches.exSelfSwitchValue([1, 2, 3]);

・Extended self switch settings
Example: When setting ON for the ID3 extended self switch of the ID2 event in the ID1 map
$gameVariables.setExSelfSwitchValue([1, 2, 3], true);

Also, for those who understand the script to some extent, in Game_Event
The following methods are defined, so by using these,
It is possible to manipulate self variables more easily.
・Game_Event#selfVariableValue(variableId)
Gets the self variable specified by variableId for the target event.

・Game_Event#setSelfVariableValue(variableId, value)
Stores the value in the self variable specified by variableId for the target event.

・Game_Event#exSelfSwitchValue(switchId)
Gets the extended self switch specified by switchId for the target event.

・Game_Event#setExSelfSwitchValue(switchId, value)
Stores the value in the extended self switch specified by switchId for the target event.

【Important point】
-Do not manipulate self variables from battle events on the editor.
Self variables are linked to map events, so from other than map events
If the variable is accessed via the event command, it will not operate normally.

-The following functions do not work properly due to specifications.
When using these functions, store them in normal variables once
Please move the value to the self variable.
- ¥v in text display
- Numerical input processing

【License】
This plugin is available under the terms of the MIT license.


@command GetSelfVariableValue
@text Self variable value acquisition
@desc Gets the value of a self variable.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg SelfVariableId
@type variable
@text Self variable ID
@default 1
@desc Specifies the self variable ID.

@arg DestVariableId
@type variable
@text Storage variable ID
@default 2
@desc Specify the variable ID that stores the acquired self variable value.


@command SetSelfVariableValue
@text Self variable value setting
@desc Set the value of the self variable.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg SelfVariableId
@type variable
@text Self variable ID
@default 1
@desc Specifies the self variable ID.

@arg Value
@type number
@text setting value
@default 0
@desc Specifies the value to set for the self variable.

@arg SrcVariableId
@type variable
@text Setting value storage variable ID
@default 0
@desc Specify the variable ID that stores the value to be set in the self variable. If you specify a direct value, specify 0 for this parameter.


@command SetSelfVariableValueByEventTags
@text Self variable value setting by event tag
@desc Sets the value of the self variable to all events with the specified event tag.

@arg EventTags
@type string[]
@text Event tag
@default []
@desc Specify the target event tag.

@arg SelfVariableId
@type variable
@text Self variable ID
@default 1
@desc Specifies the self variable ID.

@arg Value
@type number
@text setting value
@default 0
@desc Specifies the value to set for the self variable.

@arg SrcVariableId
@type variable
@text Setting value storage variable ID
@default 0
@desc Specify the variable ID that stores the value to be set in the self variable. If you specify a direct value, specify 0 for this parameter.


@command ClearSelfVariables
@text self variable clear
@desc Sets all self variables corresponding to the specified map ID and event ID to 0.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventSpecification
@type boolean
@text Whether or not event is specified
@default true
@desc When ON is specified, the target event is specified.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg SelfVariableId
@type variable
@text self variable id
@default 0
@desc If specified, only that self variable will be cleared.


@command GetExSelfSwitchValue
@text get extended self switch value
@desc Gets the extended self switch value.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg ExSelfSwitchId
@type switch
@text extended self switch ID
@default 1
@desc Specifies an extended self switch ID.

@arg DestSwitchId
@type switch
@text Destination switch ID
@default 2
@desc Specifies the switch ID that stores the acquired extended self switch value.


@command SetExSelfVariableValue
@text extended self switch value setting
@desc Sets the extended self switch value.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg ExSelfSwitchId
@type switch
@text extended self switch ID
@default 1
@desc Specifies an extended self switch ID.

@arg Value
@type boolean
@text setting value
@default true
@desc Specifies the value to set for the extended self switch.

@arg SrcSwitchId
@type switch
@text Setting value storage switch ID
@default 0
@desc Specifies the switch ID that stores the value to be set in the extended self switch. When specifying a value directly, specify 0 for this parameter.


@command SetExSelfSwitchValueByEventTags
@text Extended self switch value setting by event tag
@desc Sets the value of the self variable to all events with the specified event tag.

@arg EventTags
@type string[]
@text Event tag
@default []
@desc Specify the target event tag.

@arg ExSelfSwitchId
@type switch
@text extended self switch ID
@default 1
@desc Specifies an extended self switch ID.

@arg Value
@type boolean
@text setting value
@default true
@desc Specifies the value to set for the extended self switch.

@arg SrcSwitchId
@type switch
@text Setting value storage switch ID
@default 0
@desc Specifies the switch ID that stores the value to be set in the extended self switch. When specifying a value directly, specify 0 for this parameter.


@command ClearExSelfSwitches
@text extended self switch clear
@desc Turns off all extended self switches corresponding to the specified map ID and event ID.

@arg MapId
@type number
@text map ID
@default 1
@desc Specify the map ID. If 0 is specified, the current map ID will be applied.

@arg MapIdByVariable
@type variable
@text Map ID (variable specification)
@default 0
@desc Specify the map ID with a variable. If you set the map ID value directly, specify 0 for this parameter.

@arg EventSpecification
@type boolean
@text Whether or not event is specified
@default true
@desc When ON is specified, the target event is specified.

@arg EventId
@type number
@text Event ID
@default 1
@desc Specify the event ID. If you set the event ID value directly, specify 0 for this parameter.

@arg EventIdByVariable
@type variable
@text Event ID (variable specification)
@default 0
@desc Specify the event ID with a variable. If you set the event ID value directly, specify 0 for this parameter.

@arg ExSelfSwitchId
@type switch
@text extended self switch ID
@default 0
@desc If specified, only that extended self switch will be cleared.


@param SelfVariablePrefix
@type string
@text self variable or extend self switch prefix
@default $
@desc Specifies the variable name prefix used to identify self variables or extend self switches.

@param CommonVariablePrefix
@type string
@text common variable/common switch prefix
@default %
@desc Specifies the variable/switch name prefix used to identify common variables/switches.

@param FloatVariablePrefix
@type string
@text decimal variable prefix
@default #
@desc Specifies the variable name prefix used to identify decimal variables.

@param ErrorLanguage
@text Error message language
@type select
@option english
@value en
@option Japanese
@value ja
@default en
@desc Specifies the language for displaying errors. Normally you do not need to change this parameter.

スポンサードリンク

-MZ plugins

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