An example of this plugin in action.
Synopsis
Howdy! Do you like to sometimes use scripts in your conditional branches and other commands? Are you annoyed at how much typing that requires? Well, you're in luck!
*slaps roof of plugin* This bad boy can save you so many keystrokes! Let me show you just what it can do.
Features
$gv
First of all, you no longer need to type
every time you want to use a game variable - you now need 5 times fewer keystrokes with
. But that's not all! Instead of using
and
functions, you can read and write
values just like with regular JavaScript variables, using an array-style bracket notation to specify the variable ID. What does that mean in practise? Just take a look at those examples:
can be replaces with
- $gameVariables.setValue(42, 100)
复制代码turns into
- $gameVariables.setValue(42, $gameVariables.value(42) + 5)
复制代码becomes just
Behind the scenes, they still use regular
and
functions - for maximum plugin compatibility and to make sure event page conditions update properly (which they wouldn't if those were just simple
aliases).
$gs
As you might have guessed, this shorthand serves a very similar function to
, but it's for switches. That's about all there is to say about it, really.
Examples:
->
- $gameSwitches.setValue(42, true)
复制代码->
$ss
And of course, there's also something for self-switches! Use
to access self-switch X, e.g.
to access self-switch A of the currently running
non-parallel event. You don't even need an interpreter reference or know the ID of the that event.
Use them similarly to $gv and $gs, e.g.
- $gameSelfSwitches.setValue([$gameMap._mapId, this.eventId(), 'C'], true)
复制代码->
A check if all basic self-switches are on (doing this normally is so annoying I won't even show it) ->
- $ss.a && $ss.b && $ss.c && $ss.d
复制代码
But that's not all! Download now and you'll get 22 brand new self-switches for free! That's right, you can also use letters from F to Z the same way you'd use A, B, C and D. The editor might not let you use those in most places, but they'll work just fine in scripts.
$oss
But what about self-switches on other events? Well, there's something for those too - four things in fact! Shorthands
,
,
and
can each be used to access corresponding self-switches of another event on the same map, by adding its ID in brackets.
Examples:
- $gameSelfSwitches.value([$gameMap._mapId, 42,'A'])
复制代码->
- $gameSelfSwitches.setValue([$gameMap._mapId, 42,'B'], true)
复制代码->
But that's not all! They can also be used to access the same self-switch on a range of events simultanously, by using a string with two numbers separated by a dash to indicate the first and last ID.
will return a list of the values of self-switch A for events 11, 12, 13, 14 and 15, e.g.
- [false, true, false, false, true]
复制代码will set self-switch A on all those events to true.
There's no built-in function for doing this on non-consecutive event IDs, but it can still be done reasonably easily like so:
- [1, 5, 34, 42].forEach(id => $ossa[id] = true);
复制代码.
$es
So, the problem with switches, is that while you can now more easily access them, you still have to name them, and set them where needed... what if you didn't have to? This shorthand is here to solve that problem too! Well, sometimes. Usually not. But sometimes.
$es, standing for "event seen", is a quick way to check if the player has already interacted with another event on the same map.
will be true if the event with ID 42 has already been interacted with - so if that's all you need to know, you no longer have to use a switch just for that. And since it's set to
for a given event when it
ends, it also doubles as a quick way to check if this is the first time the player is interacting with the current event.
Note: this feature is disabled by default, since it requires a change to the engine; you can enable it in plugin parameters.
$inp
The interpreter - it's needed to do all sort of things, and while it can be accessed with
inside of an event, it can be a bit annoying to get it elsewhere. But fear not, for now you have a very simple shorthand to get the currently active non-parallel interpreter: simply type
!
$windows
And this one here is an object with a bunch of different functions to help you with retrieving windows. Details can be found in the help file, but for an example of what it can do for you, you can now open the gold window anywhere with
- $windows.get(Window_Gold).open()
复制代码instead of
- SceneManager._scene._windowLayer.children.find(x=>x instanceof Window_Gold).open()
复制代码. Or use
to get a list of all windows in the current scene, which is a really nice thing to have when trying to debug them from console.
Terms
Now, you might be asking yourself, what will all those cool features cost you? Well, it comes to a grand total of... $0. You really can't beat a price like that! It's also available under the
MIT Licence - you can use it in your non-commercial games, in your commercial games, in your own plugins, or sell T-Shirts with the code printed out on them. Credit is appreciated but not required.
I'm also very open to the idea of expanding this plugin with even more QoL features, so if you have any suggestions please feel free to send them my way.
本贴来自国际rpgmaker官方论坛作者:Mac15001900处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/scripting-shorthands-various-utilities-to-make-simple-scripts-easier.166955/