Linked Switches

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
Linked Switches

2015.11.11

by Shaz

Introduction

This plugin allows you to link switches to commands, so the command is evaluated and returned as the value of the switch. This allows you to use a switch in a conditional branch rather than a script call, or perhaps a series of commands to obtain a value and then check if it meets the condition (for example, "is the player standing on a tile with a region code of 6?", which would take 3 event commands plus the conditional branch).

How to use

Add to your plugins folder (file name is not important, but I use LinkedSwitches.js). There are no parameters to set.

You can either modify the script to add all the commands you want to link to switches, or you can set them up via plugin commands. Plugin commands remove the need to edit scripts, but mean the commands will be saved in each save file, and therefore could be manipulated by the player.

To set up links via the script, locate this section and add your commands in the appropriate format (the example below results in switch 1 being true if any party member has learned skill 12) - the example is commented out, but obviously you would not have comments on your lines:


Code:
//===========================================================================  
// Add switch commands here to build with the game rather than in save file  
// eg:  
// switchLinks[1] = '$gameParty.members().some(function(actor) { return actor.isLearnedSkill(12); })'  
//===========================================================================


To set up links via a plugin command, enter the plugin command in the appropriate format:


LinkSwitch 1 $gameParty.members().some(function(actor) { return actor.isLearnedSkill(12); })
Plugin

Download from pastebin

Credit

- Shaz

Terms

- free for use in commercial games

Notes

- this may not be reliable when used as a condition on an event page, as the conditions are only checked when a map refresh is requested. Only some actions that happen in a game cause this kind of refresh.

Feel free to post the kind of condition you want to link to a switch below, and whether you'd like to link it in the script or via a plugin command, and I (and others) will tell you the appropriate command to use.
 
Last edited:

Jeysonmcfly

Just a random Joe Schmoe
Veteran
Joined
Jan 17, 2014
Messages
54
Reaction score
15
First Language
English
Primarily Uses
Bit late to the party, but could this and/or the linked variables plugin be used for conditional skill or item usage checks in the midst of battle encounters?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
Yes, they could.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
962
Reaction score
388
First Language
Portuguese - Br
Primarily Uses
RMMV
Hello!
I'm having some difficulties making this plugin work.
I would like that, whenever an x-equipment is equipped, an X-switch is ON.
See configuration:


I've manually made an event to check if the code is right, and it is.



But the switch is never on :(
Am I doing something wrong?
RM MV 1.6.1 - Without any other plugins.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
The switch does not turn on by itself just because you change equipment. You need to USE the switch in a command somewhere and then it will go check if the leader is equipped.

However,
Notes

- this may not be reliable when used as a condition on an event page, as the conditions are only checked when a map refresh is requested. Only some actions that happen in a game cause this kind of refresh.
Changing equipment does not cause the map refresh to be triggered, so this switch would not work as a condition on an event page.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
962
Reaction score
388
First Language
Portuguese - Br
Primarily Uses
RMMV
The switch does not turn on by itself just because you change equipment. You need to USE the switch in a command somewhere and then it will go check if the leader is equipped.
Ohh i see it now! I was thinking exactly the opposite xD
Thanks!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,533
Reaction score
12,057
First Language
English
Primarily Uses
RMMV
@Eliaquim if you change your event to say If SWITCH 25 is ON, that should work. Please give that a go, and let me know if it doesn't, as that would be an issue.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Integrating Jason Perry's japan tile set while listening to Murray Atkinson's Heaven and Earth background music.
I forgot I had an account on rpgmakercentral lol
"What do you think the best place to visit on this cold days?" "Hell..."
Been so busy lately that I wonder if I should slowly start preparing the advent calendar resources so I have enough in december.
Man, I wish it was harder for mean d-holes to make me feel like crying.

Forum statistics

Threads
94,538
Messages
921,721
Members
124,402
Latest member
KINGty
Top