Linked Switches 1.0
Shaz
IntroductionShaz
Partner to the Linked Variables script, this script allows you to 'link' a switch with some other element in your game, so when you refer to that switch to retrieve its value, it goes off to check the link and returns the appropriate value. It is the equivalent of doing a Control Switches to set a switch, and then using the result in a Conditional Branch, but removes the Control Switches step.
By adding a link for the switch, you never need to do a Control Switches to set its value - it always does the check for you at the time you are referencing the switch (so it will always be completely up-to-date).
Versions
Code:
1.0 Nov 27 2013 Initial Release
Paste into a new script slot below Materials.
Edit the init_links method to add a new array element for each switch you what to link, along with a script command to eval whenever that switch is referenced.
Follow this format:
Code:
@links[variable_id] = 'eval_command'
Examples:
Make switch 1 ON when the leader’s HP is less than 50%:
Code:
@links[1] = '$game_party.leader.hp_rate < 0.5'
Code:
@links[2] = '$game_party.all_members.include?($game_actors[5]) && !$game_actors[5].battle_member?'
Code:
@links[3] = '[5, 8, 10].include?($game_map.map_id)'
Download Here
Known Issues
This is not reliable for using a switch as a condition on an event page, as the condition behind the link may change more often than event pages are polled to determine which one is active.
FAQ
Credit and Thanks
- Shaz
Author's Notes
I have added a check to ensure this still works with save files made prior to implementing this script.
If you add this script to a project that's half finished, you may go back and remove any commands that change the values in linked switches, but you do not have to - they will effectively be ignored.
Free to use in commercial games.
Give credit.