本模组提供了一个框架,用于创建基于 Game Stages 的加权随机阶段表。如果你不了解什么是游戏阶段(game stage),强烈建议你先熟悉 Game Stages 模组。本模组的基本理念是:整合包可以定义一个包含多个游戏阶段的表格,然后使用本模组提供的命令,为某位玩家从该表中随机授予一个阶段。要有效使用此模组,还需要对 CraftTweaker 脚本编写有基本的了解。
如需深入了解示例,请查阅 GitHub 页面。此外,还有一个 Discord 服务器,你可以在其中寻求帮助和建议。
命令
- /stagetable - 列出本模组添加的所有命令。
- /stagetable dump - 生成一个包含所有阶段表信息的文件。
- /stagetable award <player> <table> - 尝试从指定表格中为玩家随机授予一个阶段。
- /stagetable silentaward <player> <table> - 与 award 命令相同,但不会通知玩家。
基本术语
- 阶段表(Stage Table) - 一个包含阶段条目的命名表格。
- 阶段条目(Stage Entry) - 阶段表中的一个条目。每个条目包含一个将被授予的阶段、一个权重值以及一组条件。
- 阶段条件(Stage Condition) - 必须满足的条件,才能使某个阶段条目被授予给特定玩家。
加权随机性
权重是一种概率系统,其中各种可能结果的发生几率不相等。任意特定结果的百分比概率可以通过将该特定条目的权重除以表中所有条目的总权重来计算。例如,如果某个条目的权重为 1,而总权重为 9,则第一个结果出现的概率为 10%。当结果池需要保持灵活性时,通常会使用加权随机性。如果你仍然不确定,可以运行 dump 命令,它将根据你创建的表格生成可视化的图表。
CraftTweaker 脚本编写
以下是一个展示各种可用功能的示例脚本。如需更精确的信息,请在此处查看确切说明。
// 本脚本中使用的基本导入
import crafttweaker.player.IPlayer;
// 创建一个名为 exampleTable 的新阶段表
val testTable = stageTables.createTable("exampleTable");
// 为阶段 "one" 创建一个权重为 5 的新阶段条目。
val entryOne = testTable.createEntry("one", 5);
// 为阶段 "two" 创建一个权重为 5 的新阶段条目。
val entryTwo = testTable.createEntry("two", 5);
// 除非玩家拥有阶段 "four",否则禁止选择 entryTwo。
entryTwo.addStageCondition("four");
// 为阶段 "three" 创建一个权重为 1 的新阶段条目。
val entryThree = testTable.createEntry("three", 1);
// 使用 ZenScript 添加一个自定义条件来控制是否可获得此条目。
// 在这种情况下,仅当玩家处于创造模式时才有效。
entryThree.addCondition(function(player as IPlayer) {
return player.creative;
});
This mod provides a framework for creating weighted randomized tables of Game Stages. If you do not know what a game stage is, it is highly recommended that you familiarize yourself with the Game Stage mod first. The basic idea of this mod is that modpacks cad define a table of game stages They can then use a command provided by this mod to award a player a random stage from that table. This mod also requires a basic understanding of CraftTweaker scripting to use it effectively.
For in depth examples, please checkout the GitHub page. There is also a Discord server where you can ask for help and advice.
Commands
- /stagetable - Provides a list of all commands added by this mod.
- /stagetable dump - Generates a file containing information about all the stage tables.
- /stagetable award <player> <table> - Attempts to award a player with a random stage from the specified table.
- /stagetable silentaward <player> <table> - Same as the award command, but doesn't notify the player about it.
Basic Terminology
- Stage Table - A named table that contains stage entries.
- Stage Entry - An entry in a stage table. Each entry has a stage that will be awarded, a weight value, and a list of conditions.
- Stage Condition - A condition that must be met for a stage entry to be awardable to a given player.
Weighted Randomness
Weight is a form of probability system where the possible outcomes have unequal odds of happening The percent chance of any given outcome can be calculated by dividing the weight of a specific entry by the total weight of all entries in a table. For example if an entry has a weight of one, and the total weight is 9, there is a 10% chance of the first outcome. Weighted randomness is commonly used when the pool of outcomes needs to be flexible. If you are still unsure, you can run the dump command which will generate visual tables based on the tables that you have created.
CraftTweaker Scripting
Below is an example script that shows the various things made available. For more precise information please check here for the exact information.
// Basic imports used in this script
import crafttweaker.player.IPlayer;
// Creates a new stage table with the name exampleTable
val testTable = stageTables.createTable("exampleTable");
// Creates a new stage entry for stage "one" with a weight of 5.
val entryOne = testTable.createEntry("one", 5);
// Creates a new stage entry for stage "two" with a weight of 5.
val entryTwo = testTable.createEntry("two", 5);
// Prevent entryTwo from being selected unless the player has stage "four".
entryTwo.addStageCondition("four");
// Creates a new stage entry for stage "three" with a weight of 1.
val entryThree = testTable.createEntry("three", 1);
// Adds a custom condition to aquiring this entry using ZenScript.
// In this case, it's only valid if the player is in creative mode.
entryThree.addCondition(function(player as IPlayer) {
return player.creative;
});
评论 0
登录后参与评分
还没有评论,来抢沙发吧