Choicescript stats.txt
Choicescript stats.txt
This article is aimed at beginners to ChoiceScript. However, if you have not already done so then the best place to start would be with the very first article in this Introduction To ChoiceScript Game Development series of linked articles: A Basic Tutorial. 本文面向ChoiceScript的初学者。不过,如果您尚未开始学习,那么最佳起点应是本《ChoiceScript游戏开发入门》系列关联文章中的第一篇:《基础教程》。
In this article, we discuss the choicescript_stats.txt file (also known as the Stats Screen) where the variables that are used as Character statistics are displayed, sometimes through the use of the stat_chart command, which is also described here. 本文探讨了choicescript_stats.txt文件(也称为状态屏幕),其中显示用作角色统计数据的变量,有时通过使用stat_chart命令来实现,该命令也在此处进行说明。
Using stat_chart 使用stat_chart
The *stat_chart command is able to display variables easily and in several different ways. This command is usually used in your choicescript_stats.txt file, which governs the display of the Stats Screen and may be found in the "scenes" (..mygame\scenes) folder, but it can also be used in any ordinary scenes if required. There are no limits to how many times this command can be used in a single file. *stat_chart命令能够以多种不同方式轻松显示变量。该命令通常用于choicescript_stats.txt文件中,该文件控制状态界面的显示,可在"scenes"(..mygame\scenes)文件夹中找到,但也可根据需要用于任何普通场景。单个文件中使用此命令的次数没有限制。
NB: Any numeric variable used for displaying a percentile bar within a stat_chart should not be allowed -- as a result of scripting elsewhere -- to fall outside the 0-100 range, otherwise it will have an adverse effect on the appearance of a percentile bar. The best way to make certain this never happens is to use the "Fairmath" system: see 'arithmetic operators'. 注意:任何用于在stat_chart中显示百分比条的数字变量,不应因其他脚本的影响而超出0-100的范围,否则会对百分比条的外观产生不良影响。确保这种情况永不发生的最佳方法是使用"公平数学"系统:参见'算术运算符'。
Let's say you have three variables: the "name" string variable containing the name of the player-character; the "intelligence" numeric variable containing a number from 0 to 100; and the "wisdom" numeric variable, also a value between 0 and 100. This is how they might be used within a stat_chart for display purposes: 假设你有三个变量:包含玩家角色名称的字符串变量"name";包含0到100之间数字的数值变量"intelligence";以及同样取值范围在0到100之间的数值变量"wisdom"。以下是如何在stat_chart中使用它们进行显示的示例:
*stat_chart
text name
percent intelligence
percent wisdomWhich will display as: 这将显示为:
Stats
But what if you wanted your stat names to be capitalized in different ways? Simply type those variable names exactly as you want them to appear, so that you might end up with something like this: 但如果你希望以不同方式大写你的属性名称呢?只需按照你希望它们显示的样子准确输入这些变量名,这样你最终可能会得到类似这样的结果:
*stat_chart
text NAME
percent Intelligence
percent wIsDoMWhich will display as: 这将显示为:
Stats2
But let's say you wanted "Intelligence" to be called "Cleverness", but don't want to change the actual variable's name. Anything added to the line after the variable itself becomes the new wording for the chart, so you can type: 但假设您希望将“智力”显示为“聪慧度”,但不想更改实际变量名。在变量名之后添加的任何内容都将成为图表中的新标签,因此您可以输入:
Which will display as: 这将显示为:
Stats3.png
Note that this works with multiple words too. 请注意,此方法同样适用于多个词语。
Using opposed pairs 使用对立配对
But let's say you wanted to write something at the end of a stat bar. For example, if you wanted to make an opposed pair out of intelligence and stupidity. Simply change the percent line to opposed_pair and add another line, indented one more level, and the text intended to be displayed opposite the variable. So something like this: 但假设你想在状态条末尾写点东西。例如,如果你想创建一个智力与愚蠢的对立配对。只需将百分比行改为opposed_pair,并添加另一行,再缩进一级,写上打算显示在变量对面的文本。就像这样:
Which will display as: 这将显示为:
Stats5
Note that there is no actual "stupidity" variable; that is just text being displayed at the end of that stat bar. 请注意,这里并没有实际的“愚蠢度”变量;那只是在该状态条末尾显示的文本。
In opposed pairs you can also make the variable "intelligence" display as "Cleverness" instead, for example: 在成对出现的变量中,您也可以让变量“intelligence”显示为“Cleverness”,例如:
Displays as: 显示为:
Stats7
Stats screen in general 状态屏幕概述
Depending on the nature and content of your game, you can also use the Stats Screen for displaying a range of other information pertaining to the player-character. There are many possibilities so the best way to approach this subject is to study the stats screens of existing games, as many do different things and in various ways. 根据游戏的性质和内容,您也可以利用状态界面来展示与玩家角色相关的各类其他信息。由于可能性众多,处理这一主题的最佳方式是研究现有游戏的状态界面,因为许多游戏以不同方式实现了多样化的功能。
One good example of this variety is the actual original ChoiceScript game itself, Choice of the Dragon (full credit for this code snippet going to CoG; clicking that link will take you to the game). In Choice of the Dragon, the player can see on the Stats Screen precisely how wounded they are, according to the "wounds" variable: 这种多样性的一个很好的例子就是最初的ChoiceScript游戏本身——《龙之抉择》(此代码片段完全归功于CoG;点击该链接将带您进入游戏)。在《龙之抉择》中,玩家可以在状态屏幕上根据“wounds”变量精确查看自己受伤的程度:
0 = Uninjured 0 = 未受伤 1 = Battle-scarred 1 = 身经百战 2 = Permanently wounded 2 = 永久性伤残 3 = Permanently weakened 3 = 永久性削弱 4 = At Death's door 4 = 濒临死亡
Choice of the Dragon uses the following code to display the appropriate information: 《龙之抉择》使用以下代码来显示相应信息:
Simple Inventory System 简易库存系统
A common feature for a Stats Screen in a Choice game is an inventory of items currently held in the player's possession. Although there are several ways of doing this, a typically neat system might be as follows: 选择类游戏中状态界面的一个常见功能是显示玩家当前持有的物品清单。虽然有多种实现方式,但一种典型的简洁系统可能如下所示:
Although the items in a game would be best defined in startup.txt as permanent variables using the *create command, we have listed them here as *temp boolean variables to show the current status (true or false - i.e. whether or not this item is currently in the player's possession). In the example above, only half of the possible items are in the player's possession, so the above example would display as: 尽管游戏中的物品最好在 startup.txt 中使用 *create 命令定义为永久变量,但此处我们将它们列为 *temp 布尔变量以显示当前状态(真或假——即该物品当前是否在玩家持有中)。在上面的示例中,只有一半可能获得的物品在玩家持有中,因此上述示例将显示为:
Inventory: Eggs, Bacon, Tomatoes.
If all the possible items were presently true it would instead display as: 如果所有可能的物品当前都为真,则会显示为:
Inventory: Milk, Eggs, Bacon, Sausage, Tomatoes, Mushrooms.
If relatively new to ChoiceScript, the process of setting up and using this inventory system is described in more detail in this forum topic. 如果你是ChoiceScript的新手,可以在这个论坛主题中找到关于设置和使用此库存系统的更详细说明。
创建多状态页面导航系统|Creating a multiple stat page navigation system
有时,状态屏幕可能会变得非常冗长和杂乱。你可以将状态分到几个不同的页面中。在下面的示例中,我们将有一个通用状态页面、一个个人状态页面、一个NPC关系状态页面以及另一个术语表页面。
The temporary variable named 'stat_page' keeps track of which page the player is on by setting a new value each time the player picks an option. The menu option to "View relationship status" for example is only shown when the player is not on that page as dictated by the *if (stat_page != 2) command preceding the option.
名为'stat_page'的临时变量通过每次玩家选择选项时设置新值来跟踪玩家所在的页面。例如,“查看关系状态”的菜单选项仅在玩家不在该页面时显示,这由选项前的*if (stat_page != 2)命令决定。
Next Tutorial Article: Arithmetic operators 下一篇教程文章:算术运算符