Automatic Updating Switches and Variables
By SailCat
Introduction
This script turns switches and variables into auto-updating by binding an expression to it.
Features
XP, unlike VX or VA, allows only switches, variables and self switches to be used for events. So it is difficult to set an NPC to be available when, say, Alexus is present, or a key item is held in inventory. The two conditions are available in later maker versions.
This script makes a turnaround by setting a switch (variable as well) as always ready to represent a certain expression.
If you want a switch to indicate whether Alexus is present, write its name as "=\P.i?(\N[1])" (remove quotation mark).
If you want a switch to indicate whether a key is held, write its name as "=\I(29)>0"
The first char, =, tells the plugin that the target switch is an auto-updating one. So instead of normally turning it on or off, it will instead evaluate the expression after it.
You can far do more than what VX/VA can achieve.
To test if Alexus is wielding mithril sword, name a switch as "=\N[1].w?(4)"
To set an enemy to act in a way when party level is BELOW a certain value: name a switch as "=\L<15", and then set this switch as an action trigger, since default action triggers only allows party level ABOVE a certain value.
To test whether you have collected enough items from anywhere (drops, NPCs, treasures).
You had to:
1. Set a common event to be parallel upon some switch
2. Let the event judge the item number every frame, until you fulfill it
3. Do the processes, and turn off the switch(to prevent the process from triggering a second time)
Now with this script:
1. Set a common event to be automatic upon some switch, and name the switch such as "=\I(x)>y && !s[z]"
2. Do the processes, and turn on switch z(to prevent the process from triggering a second time)
This saves the engine from updating an extra parallel common event every frame.
To make an event like granting you Excalibur II when you reach it in less than 12 hours.
You had to:
1. Set the target event to be automatic in the first page, and use a second and third(empty) page.
2. In the first page, use operate variables to load elapsed time, and turn Self Switch A on (to stop automatic processing)
3. Set the second page to be on self switch A, and grant the reward on this page.
4. Set the third page to be empty on "self switch A" and "variable > 43200" to hide the reward when time expires.
Now with the script:
1. Name a variable as "=-\F"
2. Set the target event on "variable > -43200", and give the reward on the first page.
3. No extra processing or pages required.
How to Use
Refer to the comment before plugin script.
Terms and Credits
Feel free to use in any kind of games.
Please credit me by leaving the second line of the script.
Redistributions are OK. Secondary development is not allowed.
Ruby:
本贴来自国际rpgmaker官方论坛作者:SailCat处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/automatic-updating-switches-and-variables-xp.171725/