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

[制作教程] Switches and Variables (Part One)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    前天 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4461

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 前天 14:39 | 显示全部楼层 |阅读模式
    RMVX Ace: Switches and Variables, Part 1

    Introduction

    Howdy. Uncle Despain here, with the first of my RPG Maker VX Ace tutorials.

    This tutorial is going to tell you everything (well—almost everything) that you need to know about two of the most important features of the RPG Maker program: switches and variables. This is the first part of the tutorial, and it will teach you how and when to use switches. Part two will go a little deeper into the uses for variables.

    This tutorial is written for beginners who are diving into the depths of the program for the first time—but I'm not going to be covering the basic interface stuff (that will come in another tutorial). This tutorial is written with the assumption that you understand the most basic elements of the RPG Maker VX Ace interface.

    But before we start trying to use switches or variables, it's important to understand what they are.

    What is a Switch?

    Switches are much easier than they seem at first glance. A switch in RPG Maker VX Ace is just like the light switch on the wall next to you.





    A switch has two positions: on and off, and you can flip it whenever you want within events. Your game will keep track of which position each switch is in. When you flip a switch in an event, the game will remember if that switch is turned on or off. What those positions mean is up to you; the primary use is to activate or de-activate events, but the possibilities are limitless.





    What is a Variable?





    Variables aren't much more complicated than switches. Think about it this way: if a switch is like a light switch, then a variable is like a dimmer dial: it works the same way, but instead of only two positions (on or off), there is no limit on the amount of positions a variable can have.









    If you're familiar at all with programming, then you know that a variable is a stand-in for a number (a number that varies). In RPG Maker VX Ace, it works the same way: using events, you can set a variable to any numerical value, and the game will store that value. The variable can then be used in a bunch of different ways.





    If these descriptions still seem confusing at all, don't worry: it's time to start putting this stuff into action.





    Flicking a Switch





    We're going to start by creating a treasure chest event. After the player interacts with the chest for the first time and finds his booty, a switch will ensure that the chest remains empty. In RPG Maker VX Ace, you can use the "Quick Event Creation" command to have the program generate treasure chests for you—but for this tutorial we want to make the chest ourselves.





    Let's start off by creating a new event:













    You can choose a suitable chest graphic (remember to check the "Direction Fix" box to prevent the graphic from changing when the player interacts with it from an angle) and use an event command to add an item to the party's inventory. You'll probably want to create a message telling the player what he found, too.





    At this point, the event looks something like this:









    (click the image for a full view)



    Now, if you were to test play the game right now, you would see that the player can open the chest as many times as he wants. Infinite potions!

    The way to prevent this from happening is to use a switch. Insert a new event command at the end of your "contents" list: select "Control Switches" from the "Game Progression" command category.



    The "Control Switches" dialogue box is simple: select your switch (or a range of switches) and then choose whether to turn it on or off. If you click on the little "..." icon, you will see a list of all the switches that are being used in your game:



    You can give each switch a unique name, so that you never get confused as to what switch does what. It's useful to give each a switch a short but descriptive name. In this cast, we'll name our switch the suitably simple "Chest 1". Once you've got your switch selected, you can OK out of that, and then OK again out of the "Control Switches" box. Remember to set the operation to on.

    The contents of your event should now have this line:



    This line means that the event is setting the "001: Chest 1" switch into its on position (by default, all switches are set to off, so we are activating a switch when we turn it on). When the player opens up the chest and takes his booty, the switch will be turned on as well.

    Test play your game and give it a try. Interact with the chest, and then press "F9" on your keyboard to bring up the switches and variables debug menu. You'll see that switch 001, "Chest 1", has been turned on.



    But you can still open the chest a bunch of times and get infinite potions!

    The switch has been turned on, but it isn't doing anything yet. The next thing we need to do is make the game care that the switch has been turned on.

    Pages and Conditions

    At the top of the "Edit Event" window, there is a line of button for page controls. Go ahead and create a new page.

    An event page acts almost like a whole new event—you can give it a different graphic, different triggers, different commands, etc. Events can have up to 99 pages.

    You want to set up Page 2 to be the treasure chest after the player has opened it and taken his booty:





    (click the image for a full view)



    The page with the highest number will always be displayed by default: the game processes higher-numbered pages as having a higher priority. This means that the new page with the opened chest will overwrite the first page even before the player opens the chest, unless we set it to appear only when specific conditions are met.

    Let's make it so that Page 2 will appear after we have turned on our "Chest 1" switch.



    Now, as soon as the switch is turned on, the second page will take over. If you test the game now, everything should be working perfectly.

    Congrats! You've successfully made a chest using switches.

    Using Self Switches

    Now that you understand switches and how to use an event's pages and conditions, it's useful to know when to use a self switch instead of a regular switch.

    A self switch is the same as a regular switch, except that it only exists within the current event. The switch that we created above, "001: Chest 1", can be used in other events, because it's a regular—or a global—switch. When it's turned on, any other event in your game can recognize that—this is useful for creating side quests or developing the major story moments in your game.

    But for little events that don't affect anything other than themselves, like the chest that we just created, it is usually a better practice to use a self-switch.

    Go back to the first page of the event and delete the command that turns on the "Chest 1" switch. In its place, create a new command: select "Control Self Switch" from the "Game Progression" command category. Each event has up to four internal self switches. In this case, let's set self switch "A" to on.



    And then, on Page 2, you'd want to change the conditions as well. We're not using the "Chest 1" switch anymore—this time you'd set the condition to appear when Self Switch "A" is turned on.



    The functionality of the event will remain the same—go ahead and give it another test play.

    Because the self switch is contained within the event, you can copy and paste the same treasure chest as many times as you'd like. If they all used the same global switch, they would all open together when the player opens one of them. Now that you are using self switches, each event handles its pages and conditions internally. It's also cleaner and much more organized—you don't need to worry about switches clogging up your global switch list for every treasure chest or locked door in your game.

    That's all you need to know to get started with switches—both global and self.

    Keep an eye out for part two of this tutorial, where we'll take a look at variables.





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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 16:52 , Processed in 0.126680 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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