Difference between revisions of "Advanced Switches & Variables (YEP)"

From Yanfly.moe Wiki
Jump to navigation Jump to search
Line 12: Line 12:
  
 
  <nowiki>
 
  <nowiki>
* ============================================================================
+
============================================================================
* Introduction
+
Introduction
* ============================================================================
+
============================================================================
*
+
 
* For the advanced users out there with JavaScript experience, you can set
+
For the advanced users out there with JavaScript experience, you can set
* certain switches and variables to return data about the game through pieces
+
certain switches and variables to return data about the game through pieces
* of code on the get go. This can be used for event page conditions, enemy AI
+
of code on the get go. This can be used for event page conditions, enemy AI
* conditions, troop page conditions, and more!
+
conditions, troop page conditions, and more!
*
+
 
* ============================================================================
+
============================================================================
* Instructions
+
Instructions
* ============================================================================
+
============================================================================
*
+
 
* To use this plugin, name the switches or variables that you want to utilize
+
To use this plugin, name the switches or variables that you want to utilize
* code effects with the following format:
+
code effects with the following format:
*
+
 
*   Eval: code
+
   Eval: code
*
+
 
* This will make the switch or variable run the piece of code after the
+
This will make the switch or variable run the piece of code after the
* 'Eval:' marker. The code is used for a switch, it ought to return a 'true' or
+
'Eval:' marker. The code is used for a switch, it ought to return a 'true' or
* 'false' boolean. If the code is used for a variable, it ought to return a
+
'false' boolean. If the code is used for a variable, it ought to return a
* numeric value for comparison.
+
numeric value for comparison.
*
+
 
* For example, a switch named 'Eval: $gameActors.actor(1).isLearnedSkill(5)',
+
For example, a switch named 'Eval: $gameActors.actor(1).isLearnedSkill(5)',
* then it will return true if Actor 1 has skill 5 learned or not. This can be
+
then it will return true if Actor 1 has skill 5 learned or not. This can be
* used for things like making a skill with 'True Sight' and making certain
+
used for things like making a skill with 'True Sight' and making certain
* things appear visible on the map if the actor has that skill.
+
things appear visible on the map if the actor has that skill.
*
+
 
* While variables can insert their own JavaScript code easily thanks to the
+
While variables can insert their own JavaScript code easily thanks to the
* help of the 'Script' option in the Control Variables event, you can save
+
help of the 'Script' option in the Control Variables event, you can save
* yourself the extra step by just naming a variable 'Eval: $gameParty.gold()'.
+
yourself the extra step by just naming a variable 'Eval: $gameParty.gold()'.
* This will automatically make it calculate the amount of gold the party has
+
This will automatically make it calculate the amount of gold the party has
* and reference it with the variable.
+
and reference it with the variable.
*
+
 
* !! WARNING !!
+
!! WARNING !!
*
+
 
* If you are using this as an event's page condition, keep in mind that any
+
If you are using this as an event's page condition, keep in mind that any
* changes made from events on the map will not reflect the changes made to
+
changes made from events on the map will not reflect the changes made to
* reference those switches immediately. For that, you will have to refresh the
+
reference those switches immediately. For that, you will have to refresh the
* map, which can be done using the plugin command below:
+
map, which can be done using the plugin command below:
*
+
 
* ============================================================================
+
============================================================================
* Plugin Commands
+
Plugin Commands
* ============================================================================
+
============================================================================
*
+
 
* These plugin commands can be used to immediately refresh a map or troop
+
These plugin commands can be used to immediately refresh a map or troop
* troop event to ensure that switch/variable data gets noticed and triggered
+
troop event to ensure that switch/variable data gets noticed and triggered
* or updated upon your call.
+
or updated upon your call.
*
+
 
* Plugin Command:
+
Plugin Command:
*
+
 
*   RefreshMap
+
   RefreshMap
*   - This will refresh all of the map's events. This will update any page
+
   - This will refresh all of the map's events. This will update any page
*   conditions with Advanced Switches or Variables that may have changed
+
   conditions with Advanced Switches or Variables that may have changed
*   values prior to using this plugin command. This can only be used outside
+
   values prior to using this plugin command. This can only be used outside
*   of battle!
+
   of battle!
*
+
 
*   RefreshTroop
+
   RefreshTroop
*   - This will refresh the current event interpreter in battle. This will
+
   - This will refresh the current event interpreter in battle. This will
*   update any page condition within the current troop that utilizes Advanced
+
   update any page condition within the current troop that utilizes Advanced
*   Switches or Variables that may have changed values prior to using this
+
   Switches or Variables that may have changed values prior to using this
*   plugin command.
+
   plugin command.
*   * NOTE: If you are using the Battle Engine Core, using this won't be
+
   * NOTE: If you are using the Battle Engine Core, using this won't be
*   necessary for the majority of the time.
+
   necessary for the majority of the time.
*
+
 
* ============================================================================
+
============================================================================
* Examples
+
Examples
* ============================================================================
+
============================================================================
*
+
 
* Here are some examples that you can use Advanced Switches and Variables for!
+
Here are some examples that you can use Advanced Switches and Variables for!
*
+
 
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Switches
+
Switches
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
+
 
* Eval: $gameActors.actor(1).isLearnedSkill(5)
+
Eval: $gameActors.actor(1).isLearnedSkill(5)
* - This will make a check if Actor 1 (in the database) has learned skill 5
+
- This will make a check if Actor 1 (in the database) has learned skill 5
* (in the database). This can be used for some skills like 'True Sight' to
+
(in the database). This can be used for some skills like 'True Sight' to
* certain events appear differently on the map or certain events happen in
+
certain events appear differently on the map or certain events happen in
* battle (like seeing through an enemy's disguise).
+
battle (like seeing through an enemy's disguise).
*
+
 
* Eval: $gameActors.actor(2).isStateAffected(10)
+
Eval: $gameActors.actor(2).isStateAffected(10)
* - This will make a check to see if Actor 2 is affected by state 10 (in the
+
- This will make a check to see if Actor 2 is affected by state 10 (in the
* database). If the actor is affected by it, then the switch will return true.
+
database). If the actor is affected by it, then the switch will return true.
* Otherwise, it will return false.
+
Otherwise, it will return false.
*
+
 
* Eval: $gameActors.actor(3).isEquipped($dataWeapons[100])
+
Eval: $gameActors.actor(3).isEquipped($dataWeapons[100])
* - This will make a check to see if Actor 3 (in the database) has Weapon 100
+
- This will make a check to see if Actor 3 (in the database) has Weapon 100
* (in the database) equipped. If it does, then the switch will return true.
+
(in the database) equipped. If it does, then the switch will return true.
* Otherwise, it will return false.
+
Otherwise, it will return false.
*
+
 
* Eval: $gameActors.actor(4).isEquipped($dataArmors[200])
+
Eval: $gameActors.actor(4).isEquipped($dataArmors[200])
* - This will make a check to see if Actor 4 (in the database) has Armor 200
+
- This will make a check to see if Actor 4 (in the database) has Armor 200
* (in the database) equipped. If it does, then the switch will return true.
+
(in the database) equipped. If it does, then the switch will return true.
* Otherwise, it will return false.
+
Otherwise, it will return false.
*
+
 
* Eval: $gameActors.actor(5).isDead()
+
Eval: $gameActors.actor(5).isDead()
* - This will make a check to see if Actor 5 is currently dead. Being dead
+
- This will make a check to see if Actor 5 is currently dead. Being dead
* will require that the actor is afflicted with the death state. If the actor
+
will require that the actor is afflicted with the death state. If the actor
* is dead, the switch will return true. Otherwise, it will return false.
+
is dead, the switch will return true. Otherwise, it will return false.
*
+
 
* Eval: $gameActors.actor(6).isAlive()
+
Eval: $gameActors.actor(6).isAlive()
* - This will make a check to see if Actor 6 is currently alive. Being alive
+
- This will make a check to see if Actor 6 is currently alive. Being alive
* will require that the actor is not afflicted with the death state. If the
+
will require that the actor is not afflicted with the death state. If the
* actor is alive, the switch will return true. Otherwise, it will return false.
+
actor is alive, the switch will return true. Otherwise, it will return false.
*
+
 
* Eval: $gameVariables.value(2) < 3
+
Eval: $gameVariables.value(2) < 3
* - You know how map event page conditions can only make checks if a variable
+
- You know how map event page conditions can only make checks if a variable
* is only greater than or equal to a value? Well, now you can do the opposite
+
is only greater than or equal to a value? Well, now you can do the opposite
* and check if a variable is less than a certain value. The example used above
+
and check if a variable is less than a certain value. The example used above
* will check if Variable 2 has a value less than 3 (but not equal to).
+
will check if Variable 2 has a value less than 3 (but not equal to).
*
+
 
* Eval: $gameSelfSwitches.value([10,20,'A'])
+
Eval: $gameSelfSwitches.value([10,20,'A'])
* - This will allow an event to use another event's self switch case to
+
- This will allow an event to use another event's self switch case to
* determine its condition. The example above checks if Map 10, Event 20's 'A'
+
determine its condition. The example above checks if Map 10, Event 20's 'A'
* self switch is turned on.
+
self switch is turned on.
*
+
 
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Variables
+
Variables
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
+
 
* Eval: $gameParty.leader().actorId()
+
Eval: $gameParty.leader().actorId()
* - This will return the party leader's actor ID. This can be useful for
+
- This will return the party leader's actor ID. This can be useful for
* certain events that may have different reactions depending on who your party
+
certain events that may have different reactions depending on who your party
* leader is at the time.
+
leader is at the time.
*
+
 
* Eval: $gameParty.gold()
+
Eval: $gameParty.gold()
* - This will return the party's exact amount of gold. This can also be used
+
- This will return the party's exact amount of gold. This can also be used
* in some event's pages to make bags of gold appear in the player's HQ to show
+
in some event's pages to make bags of gold appear in the player's HQ to show
* just how rich the player is.
+
just how rich the player is.
*
+
 
* Eval: $gameParty.steps()
+
Eval: $gameParty.steps()
* - This will return the amount of steps the player has walked. This can be
+
- This will return the amount of steps the player has walked. This can be
* used in ways where a trophy may appear in the player's HQ depending on how
+
used in ways where a trophy may appear in the player's HQ depending on how
* many steps the player has walked.
+
many steps the player has walked.
*
+
 
* Eval: $gameParty.aliveMembers().length
+
Eval: $gameParty.aliveMembers().length
* - This will return the number of alive members in the current party. Best if
+
- This will return the number of alive members in the current party. Best if
* used in battle when trying to make different things happen depending on the
+
used in battle when trying to make different things happen depending on the
* number of allies currently alive in battle.
+
number of allies currently alive in battle.
*
+
 
* Eval: $gameParty.deadMembers().length
+
Eval: $gameParty.deadMembers().length
* - This will return the opposite: the number of dead members in the current
+
- This will return the opposite: the number of dead members in the current
* party. Also best used in battle when trying to make different things happen
+
party. Also best used in battle when trying to make different things happen
* depending on the number of allies that are dead in battle.
+
depending on the number of allies that are dead in battle.
*
+
 
* Eval: $gameParty.highestLevel()
+
Eval: $gameParty.highestLevel()
* - This will return the party's current highest level member. In battle, this
+
- This will return the party's current highest level member. In battle, this
* will refer to the active party in action. Outside of battle, it pertains to
+
will refer to the active party in action. Outside of battle, it pertains to
* any of the members in the active party or reserve party.
+
any of the members in the active party or reserve party.
*
+
 
* Eval: $gameParty.numItems($dataItems[1])
+
Eval: $gameParty.numItems($dataItems[1])
* Eval: $gameParty.numItems($dataWeapons[2])
+
Eval: $gameParty.numItems($dataWeapons[2])
* Eval: $gameParty.numItems($dataArmors[3])
+
Eval: $gameParty.numItems($dataArmors[3])
* - This will return the actual number of items as the condition instead of
+
- This will return the actual number of items as the condition instead of
* whether or not the party has that item. For weapons and armors, this will
+
whether or not the party has that item. For weapons and armors, this will
* not include those that are equipped.
+
not include those that are equipped.
*
+
 
* ============================================================================
+
============================================================================
* Changelog
+
Changelog
* ============================================================================
+
============================================================================
*
+
 
* Version 1.02:
+
Version 1.02:
* - Bypass the isDevToolsOpen() error when bad code is inserted into a script
+
- Bypass the isDevToolsOpen() error when bad code is inserted into a script
* call or custom Lunatic Mode code segment due to updating to MV 1.6.1.
+
call or custom Lunatic Mode code segment due to updating to MV 1.6.1.
*
+
 
* Version 1.01:
+
Version 1.01:
* - Bug fixed to prevent compatibility problems with the Debugger.
+
- Bug fixed to prevent compatibility problems with the Debugger.
*
+
 
* Version 1.00:
+
Version 1.00:
* - Finished Plugin!
+
- Finished Plugin!
*
+
 
* ============================================================================
+
============================================================================
* End of Helpfile
+
End of Helpfile
* ============================================================================
+
============================================================================
 
</nowiki>
 
</nowiki>

Revision as of 13:55, 20 June 2019

Welcome to the wiki! This is where you can find resources from Yanfly.moe, Ækashics.moe,
VisuStella, Caz Wolf, Fallen Angel Olivia, Atelier Irina, and other affiliated content creators.



Download

System

This is a plugin created for RPG Maker MV.

For help on how to install plugins, click here.

For help on how to update plugins, click here.

Got errors with your RPG Maker MV plugin? Click here.


Masterarbeit Writer

Yanfly Engine Plugins

This plugin is a part of the Yanfly Engine Plugins library.


Help File

============================================================================
Introduction
============================================================================

For the advanced users out there with JavaScript experience, you can set
certain switches and variables to return data about the game through pieces
of code on the get go. This can be used for event page conditions, enemy AI
conditions, troop page conditions, and more!

============================================================================
Instructions
============================================================================

To use this plugin, name the switches or variables that you want to utilize
code effects with the following format:

  Eval: code

This will make the switch or variable run the piece of code after the
'Eval:' marker. The code is used for a switch, it ought to return a 'true' or
'false' boolean. If the code is used for a variable, it ought to return a
numeric value for comparison.

For example, a switch named 'Eval: $gameActors.actor(1).isLearnedSkill(5)',
then it will return true if Actor 1 has skill 5 learned or not. This can be
used for things like making a skill with 'True Sight' and making certain
things appear visible on the map if the actor has that skill.

While variables can insert their own JavaScript code easily thanks to the
help of the 'Script' option in the Control Variables event, you can save
yourself the extra step by just naming a variable 'Eval: $gameParty.gold()'.
This will automatically make it calculate the amount of gold the party has
and reference it with the variable.

!! WARNING !!

If you are using this as an event's page condition, keep in mind that any
changes made from events on the map will not reflect the changes made to
reference those switches immediately. For that, you will have to refresh the
map, which can be done using the plugin command below:

============================================================================
Plugin Commands
============================================================================

These plugin commands can be used to immediately refresh a map or troop
troop event to ensure that switch/variable data gets noticed and triggered
or updated upon your call.

Plugin Command:

  RefreshMap
  - This will refresh all of the map's events. This will update any page
  conditions with Advanced Switches or Variables that may have changed
  values prior to using this plugin command. This can only be used outside
  of battle!

  RefreshTroop
  - This will refresh the current event interpreter in battle. This will
  update any page condition within the current troop that utilizes Advanced
  Switches or Variables that may have changed values prior to using this
  plugin command.
  * NOTE: If you are using the Battle Engine Core, using this won't be
  necessary for the majority of the time.

============================================================================
Examples
============================================================================

Here are some examples that you can use Advanced Switches and Variables for!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Switches
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Eval: $gameActors.actor(1).isLearnedSkill(5)
- This will make a check if Actor 1 (in the database) has learned skill 5
(in the database). This can be used for some skills like 'True Sight' to
certain events appear differently on the map or certain events happen in
battle (like seeing through an enemy's disguise).

Eval: $gameActors.actor(2).isStateAffected(10)
- This will make a check to see if Actor 2 is affected by state 10 (in the
database). If the actor is affected by it, then the switch will return true.
Otherwise, it will return false.

Eval: $gameActors.actor(3).isEquipped($dataWeapons[100])
- This will make a check to see if Actor 3 (in the database) has Weapon 100
(in the database) equipped. If it does, then the switch will return true.
Otherwise, it will return false.

Eval: $gameActors.actor(4).isEquipped($dataArmors[200])
- This will make a check to see if Actor 4 (in the database) has Armor 200
(in the database) equipped. If it does, then the switch will return true.
Otherwise, it will return false.

Eval: $gameActors.actor(5).isDead()
- This will make a check to see if Actor 5 is currently dead. Being dead
will require that the actor is afflicted with the death state. If the actor
is dead, the switch will return true. Otherwise, it will return false.

Eval: $gameActors.actor(6).isAlive()
- This will make a check to see if Actor 6 is currently alive. Being alive
will require that the actor is not afflicted with the death state. If the
actor is alive, the switch will return true. Otherwise, it will return false.

Eval: $gameVariables.value(2) < 3
- You know how map event page conditions can only make checks if a variable
is only greater than or equal to a value? Well, now you can do the opposite
and check if a variable is less than a certain value. The example used above
will check if Variable 2 has a value less than 3 (but not equal to).

Eval: $gameSelfSwitches.value([10,20,'A'])
- This will allow an event to use another event's self switch case to
determine its condition. The example above checks if Map 10, Event 20's 'A'
self switch is turned on.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Variables
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Eval: $gameParty.leader().actorId()
- This will return the party leader's actor ID. This can be useful for
certain events that may have different reactions depending on who your party
leader is at the time.

Eval: $gameParty.gold()
- This will return the party's exact amount of gold. This can also be used
in some event's pages to make bags of gold appear in the player's HQ to show
just how rich the player is.

Eval: $gameParty.steps()
- This will return the amount of steps the player has walked. This can be
used in ways where a trophy may appear in the player's HQ depending on how
many steps the player has walked.

Eval: $gameParty.aliveMembers().length
- This will return the number of alive members in the current party. Best if
used in battle when trying to make different things happen depending on the
number of allies currently alive in battle.

Eval: $gameParty.deadMembers().length
- This will return the opposite: the number of dead members in the current
party. Also best used in battle when trying to make different things happen
depending on the number of allies that are dead in battle.

Eval: $gameParty.highestLevel()
- This will return the party's current highest level member. In battle, this
will refer to the active party in action. Outside of battle, it pertains to
any of the members in the active party or reserve party.

Eval: $gameParty.numItems($dataItems[1])
Eval: $gameParty.numItems($dataWeapons[2])
Eval: $gameParty.numItems($dataArmors[3])
- This will return the actual number of items as the condition instead of
whether or not the party has that item. For weapons and armors, this will
not include those that are equipped.

============================================================================
Changelog
============================================================================

Version 1.02:
- Bypass the isDevToolsOpen() error when bad code is inserted into a script
call or custom Lunatic Mode code segment due to updating to MV 1.6.1.

Version 1.01:
- Bug fixed to prevent compatibility problems with the Debugger.

Version 1.00:
- Finished Plugin!

============================================================================
End of Helpfile
============================================================================