Linked Switches 1.0
Shaz
Introduction
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
Spoiler Code:
- 1.0 Nov 27 2013 Initial Release
复制代码
How to Use
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'
复制代码
where
eval_command returns either a true or false value.
Examples:
Make switch 1 ON when the leader’s HP is less than 50%:
Code:
- @links[1] = '$game_party.leader.hp_rate < 0.5'
复制代码
Make switch 2 ON when actor 5 is in the party but not a battler:
Code:
- @links[2] = '$game_party.all_members.include?($game_actors[5]) && !$game_actors[5].battle_member?'
复制代码
Make switch 3 ON when the player is on maps 5, 8 or 10 (maybe you want to run a parallel process common event on those maps):
Code:
- @links[3] = '[5, 8, 10].include?($game_map.map_id)'
复制代码
Script
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.
本贴来自国际rpgmaker官方论坛作者:Shaz处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/linked-switches.20349/