じ☆ve冰风 发表于 2026-7-7 12:31:48

[RMXP] Item-Based Flashlight System

This tutorial is how to make an item-based flashlight system, which allows the player to toggle the flashlight on and off from the item menu. No scripts. No huge amounts of parallel process events on each map. All common events. In order to start the tutorial, you need to download the two (2) attached images first.





I'm no coder, this is simply from about two hours’ worth of frustration and knowing how to make a picture follow you on the map. If you have any questions or get stuck, go ahead and badger me for answers.

~///~​
 ​
STEP ONE
THE SWITCHES

Possibly the easiest part of this tutorial. Head into the Event Commands panel and then select Control Switches. Next, you simply have to create a switch and call it Flashlight ON.

https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/1531928_732857136749380_3381324117713516305_n.jpg?oh=0c5fcb7af697f645fe2bbce85ee50047&oe=54833A99&__gda__=1418984100_ba2186f0709a44ece23c7b0b2486911b

Aaaand that's it! No more switches to make. Onto the next step.

STEP TWO

CREATING THE COMMON EVENTS

To those who're new to RMXP, common events can seem daunting but trust me - they can save you a lot of time, effort and lag in your game. To start off, you need to make three (3) common events. Name however you'd like personally, but to help follow, name these Flashlight OBTAIN, Flashlight ON and Flashlight OFF.

https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/10500363_732859813415779_4546222492353719000_n.jpg?oh=5aa41051acd9461e1f26b75c2cb15a59&oe=549B8796&__gda__=1422892618_eb4757a1a464cc9a51b56e2ebd4e9567

Both Flashlight OBTAIN and Flashlight OFF need to be blank. That means they have no trigger and no condition switch.

However Flashlight ON needs to have a parallel trigger and the switch set to be flashlight ON.

https://scontent-b-lhr.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/10419973_732860006749093_5403356760054798_n.jpg?oh=f67f5e1310cc827a9778109964ace536&oe=54853263

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/10636063_732860186749075_6518278795884347837_n.jpg?oh=8b1b345c295b6744328cf848fecd92ff&oe=54966294&__gda__=1419191624_6d600fb2a266b497c2cb11aca9b55815

Nothing more can be done until we next create the actual flashlight items.

STEP THREE
THE FLASHLIGHT(S)

In the Items section of the Database, you need to create two (2) separate flashlights. Doing this is crucial as it allows the ability to toggle the light on and off whilst making it still seem to be the same item to the player. Name them identically as Flashlight, and then change everything to look just like in the picture. In this tutorial, they will be listed as Flashlight 001 and Flashlight 002 for clarity. You don’t have to add a Menu Use SE, but I prefer to add one.

https://scontent-b-lhr.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/10620736_732867610081666_2688731767559004264_n.jpg?oh=a0ad7d50beef4684269bb7ae5ed05f96&oe=548BAB29

https://scontent-b-lhr.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/10414895_732873926747701_2928643632263116832_n.jpg?oh=1ba55b59050aec8aaf8e549232da6398&oe=54CBD09D

Two main things about the flashlights is that:


[*]They can't be consumable. This means that when the player "uses" the flashlight, it appears whilst using them to be as if it's used up by having the amount value drop from one (1) to zero (0). This is incorrect as in reality, all the character is doing is flicking a switch on the torch.
[*]Their common events are different. With Flashlight 001, the common event will be set to Flashlight GAIN whereas with Flashlight 002, the common event will be set to Flashlight OFF.
If both of your flashlights look like this, you’re set to go back to the Common Events.

STEP FOUR
THE COMMON EVENTS – REDUX

Go to Flashlight OBTAIN and create two events – one which will decrease (and remove) Flashlight 001 and then one which will increase (and add) Flashlight 002. This is so that when the player “turns on” the flashlight, the item which “turns on” the flashlight will be removed and replaced with the item that “turns off” the flashlight.

https://scontent-b-lhr.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/10590635_732874826747611_3981046990907805735_n.jpg?oh=2c49165690573e0f2ac5b3c12eb41571&oe=548D559A

Finally underneath, add a control switch what will turn on flashlight ON, as well as the next common event, Flashlight ON.

https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/14963_732877170080710_1272394386723991049_n.jpg?oh=bac21437f9cf59c9528c679a56c34882&oe=54CDECAA&__gda__=1419730119_057a8ff78d86d330eb78ec6d206ffd77

Go to Flashlight ON now. Start by creating an Erase Picture event. Make sure that this picture is set to two (2) otherwise it won’t work. After this, select Change Screen Colour Tone and set it to how it is in the picture. You can have it your own way, but personally I think this one works well with the flashlight / darkness on screen pictures.

https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/16764_732879566747137_4950509525411212877_n.jpg?oh=f03e9b59f5c0daa181983d7f5c2757c5&oe=5487E6A7&__gda__=1422784986_aea5664abeb6c4f133e537ac9bffaeda

Next is the fiddly bit which will make the image that appears on screen actually follow your character. Select Control Variables and then create two (2) separate variables - Player X and Player Y. For now, only use Player X. Have the Operation to be Set and then have the Operand to be the Character's Screen X. Be careful that it is definitely SCREEN and not MAP, otherwise it won't follow you, which is a common mistake. Repeat the process again, but change everything from X to Y.

https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10670029_732880866747007_3992324490857816723_n.jpg?oh=c95f9eda53d993d026342955701cca21&oe=54CBA042&__gda__=1418514426_7dfce36216667e41ea7cc6e11dae25ae

Finally to add the flashlight image. Select Show Picture and set it to number two (2). Use the flashlight graphic you downloaded from here. Make sure that the Variable is set to Player X for X and Player Y for Y. This means that the image will be recognised as the one that is going to be following you about.

https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10653530_732883950080032_5111462278176424528_n.jpg?oh=95b8569737e9e3f06e6ba5f39b03c215&oe=54836CB2&__gda__=1422504458_8691286f96ec7d9e7e2ae7f23ed80eff

When this is finished, you can now move onto the last common event!

Select Flashlight OFF. This common event is the easiest, as you've already put down everything you needed, it's now just a matter of copy-pasting with minor changes. Go back to Flashlight GAIN and copy-paste everything from there to Flashlight OFF.

Reverse everything. This now means that Flashlight 001 is increased, Flashlight 002 is decreased and the switch is turned off, as in the picture below.

https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/10672336_732892453412515_7797312747094455365_n.jpg?oh=25afafc057953958450b8be4f44d6513&oe=549F4D57&__gda__=1419851147_84da598fd4cb8ab7e8694d725f01e77b

Next, go back to Flashlight ON and once again, copy-paste everything over toFlashlight OFF. Like before, edits are needed. Though thankfully not much needs to be changed. Go to Erase Picture and change it to two (2) before simply changing the Show Picture to display the second picture you downloaded here - the completely black one. This means that when the flashlight is "turned off", it goes back to darkness.

https://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-xaf1/v/t1.0-9/10603450_732893433412417_5581293020899090707_n.jpg?oh=66c7ab9b712d08bdf3b410a77077008b&oe=548D7684&__gda__=1418821429_f05e9d8ab3b32fa6e765afcdb8d3cee2

If you do not want this to happen, simply delete the Control Variables and Show Picture section of Flashlight OFF, before setting the Change Screen Colour Tone back to default. This is handy if you have a flashlight that is simply a glow around the character.

I advise before playing about in RMXP to see if it worked to double check if you've got everything right! That might save you the trouble (and frustration) of thinking this doesn't work. If problems still appear, like I have stated before, go ahead and badger me! cc:


本贴来自国际rpgmaker官方论坛作者:b a c t e r i a处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/rmxp-item-based-flashlight-system.31971/
页: [1]
查看完整版本: [RMXP] Item-Based Flashlight System