设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 52|回复: 0

[交流讨论] Making a "Press Buttons in Correct Order" puzzle

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    21262
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    25800

    灌水之王

    发表于 昨天 21:20 | 显示全部楼层 |阅读模式
    This is the kind of puzzle where you have 4 buttons in a room and you have to press them in the correct order, to open a door or give some other reward.  There are already a few tutorials out there, but this is a nice simple one, requiring just a single switch, a variable, and a common event, in addition to your button and door events.  It would be easy to modify the instructions below to use up to 9 buttons.

    I will give instructions for two versions of the puzzle.  In one, the player has to press all 4 buttons before they find out whether they solved the puzzle or not.  In the other, the puzzle will reset as soon as an incorrect button is pressed.  Steps 1 and 2 are the same for both versions.

    The screenshots below are from Ace, but I will point out where you need to do something different for MV, XP, or 2K/2K3.

    Overview

    Here's how it will work.  Each button will have a different number allocated to it.  We will track the button sequence in a single variable.  Each time a button is pressed, the variable will be updated by moving all the digits to the left and adding the number allocated to that button.

    If the player presses the buttons in the correct order, the variable will be set to 1 after the first button, 12 after the second button, 123 after the third button, and 1234 after the fourth button.





    Step 1 - create your first button

    Create the event for your first button.  On tab 1, set the sprite to the out/off image.  On tab 2, set the sprite to the in/on image.  Add your commands to tab 1.

    If you want your button to animate, start off by setting a move route to turn left, then right, then down, with a brief wait in between (this is like the door and chest quick events).  If you have your events set to Direction Fix, make sure to turn that off at the start of the move route, and then on again at the end.  Set the move route to wait for completion.

    Now turn on self switch A.  RM2K/2K3 doesn't have self switches, so you will have to use a regular switch.  VX Ace Lite has self switches, but no access to the script command, which we need later, so use regular switches if you have Ace Lite.

    Change the variable you're going to use to track the button sequence.  First, multiply it by 10, to move all the digits one place to the left.  Then add 1 to the variable.  When you start a new game, this variable will be 0.  And when we reset the puzzle, we'll change it back to 0 again.

    Finally, call a common event that will contain the logic to see if the puzzle has been solved, or needs to be reset.  We'll create that in a few minutes.

    On tab 2, set the condition to self switch A.  RM2K/2K3, Ace Lite will use the switch that you turned on in tab 1.





    Step 2 - create the rest of the buttons

    Now that your first button is done, go ahead and copy/paste it for each additional button in the puzzle.

    Go into each one and change the graphic on both pages so they are different coloured buttons (if you want them all to look different), and change the number you add to the variable, so each button adds a different number.

    To make it easy, my buttons are numbered 1, 2, 3 and 4, and they must be pressed in the order 1, 2, 3 and 4, and those are the numbers that get added to the variable for each one.  I can move around the events in the scene as much as I want later, but it's easier to just create them in the order they should be pressed.

    RM2K/2K3 and VX Ace Lite will also need to change the switch being turned on in the tab 1 commands, and the switch used as a condition in the tab 2 commands.  Make sure each button uses a different switch.

    Step 3 - create the "puzzle solved" common event

    The first version is where the player will only know if the puzzle is solved after pressing all the buttons.  So we only want to do something if all buttons have been pressed.  This means the variable will be 4 digits long, so > 1000.  For each extra button, there will need to be an extra digit, so an extra 0.

    If the variable is > 1000, check to see if it represents the correct button order.  In my example, buttons must be pressed in the order 1, 2, 3 then 4, so the variable should be 1234.  If it is, give the player the reward - turn on the switch that controls the door, or the chest.  If the sequence isn't correct, we'll reset the puzzle.  This means setting the variable back to 0 to start again, and resetting all of the buttons.  XP, VX, VX Ace and MV can do this with a Script call to change the self switches, passing in the map and event ids, with no leading zeros, and the self switch id.  2K/2K3 and VX Ace Lite don't have a Script command, so they will just turn off all the switches that control the buttons.

    The second Else in the screenshot below is unnecessary - feel free to leave it out.






    The second version is where the puzzle will reset the moment the player pushes a button in the wrong order.  In this version, there is one correct value for the variable (1234) that will solve the puzzle, three on-the-right-track values (1, 12, and 123) where we won't do anything, and every other value means they've pressed the wrong button, so we'll reset the puzzle.

    So first, do the test to see if the puzzle is solved.  If the variable shows the correct sequence, 1234, turn on the switch to indicate the puzzle is complete so the player can get their reward.  Otherwise, add a series of conditional branches to make sure the variable doesn't hold one of the other 3 values.  If it is not any of those values, reset the puzzle, following the same steps as above.






    VX / VX Ace - use the commands as shown in the code above:
                    Code:       
    $game_self_switches[[1, 1, 'A']] = false$game_self_switches[[1, 2, 'A']] = false$game_self_switches[[1, 3, 'A']] = false$game_self_switches[[1, 4, 'A']] = false


    The first number is the map id, the second number is the event id, and the character is the self switch id, surrounded by quotes.  Do not put leading zeros on the map or event ids.

    XP - do the same as above, but add this at the end:
                    Code:       
    $game_map.need_refresh = true


    MV - is slightly different:
                    Code:       
    $gameSelfSwitches.setValue([1, 1, 'A'], false);$gameSelfSwitches.setValue([1, 2, 'A'], false);$gameSelfSwitches.setValue([1, 3, 'A'], false);$gameSelfSwitches.setValue([1, 4, 'A'], false);


    2K/2K3 and VX Ace Lite - there is no Script command, so just turn off the switches for each of the button events.

    VX, VX Ace and MV may have an issue with the button image not resetting when you reset the puzzle.  If that happens, add a Move Route in the common event, for each button, with the command Turn Down.

    Step 4 - the reward

    Of course, there will probably be another event, maybe on this map, maybe on another, that is conditioned by the "puzzle solved" switch.  It could be a door, or a chest.  Or it could be something that happens straight away (like a spirit that appears and gives you the ultimate weapon) - in that case, you could put the reward straight into the common event rather than using another event that the player has to locate.


    本贴来自国际rpgmaker官方论坛作者:Shaz处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/making-a-press-buttons-in-correct-order-puzzle.70966/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-10 00:10 , Processed in 0.127931 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表