Stage Tables
This mod provides a system for creating weighted tables of random game stage distribution. It is strongly recommended to familiarize yourself with the basics of the Game Stages modification before use if you are not familiar with it. The core concept is that pack creators can define sets of stages, and then use a special command to award players with random stages from that table. Effective use requires basic understanding of the CraftTweaker scripting language.
Commands
- /stagetable - displays a list of all available mod commands
- /stagetable dump - generates a file with detailed information about all stage tables
- /stagetable award
- attempts to award the specified player with a random stage from the selected table
- /stagetable silentaward
- similar to the previous command, but without notifying the player
Basic Concepts
- Stage Table - named table containing stage entries
- Stage Entry - table element containing information about the awarded stage, weight value, and list of conditions
- Stage Condition - requirement that must be met for the player to receive the corresponding entry
Weighted Randomness
The weight system represents a probability mechanism where different outcomes have unequal chances of occurrence. The percentage probability of a specific outcome is calculated by dividing that entry's weight by the total weight of all table elements. For example, if an entry has a weight of 1, and the total table weight is 9, the probability would be 10%. This system is particularly useful when flexibility in the set of possible outcomes is required. For visual data representation, you can use the dump command, which will generate visualized tables.
Working with CraftTweaker
Example script demonstrating various mod capabilities:
// Basic imports used in the script import crafttweaker.player.IPlayer; // Creating a new stage table with the name exampleTable val testTable = stageTables.createTable("exampleTable"); // Creating a new entry for stage "one" with weight 5 val entryOne = testTable.createEntry("one", 5); // Creating a new entry for stage "two" with weight 5 val entryTwo = testTable.createEntry("two", 5); // Blocking selection of entryTwo until the player has stage "four" entryTwo.addStageCondition("four"); // Creating a new entry for stage "three" with weight 1 val entryThree = testTable.createEntry("three", 1); // Adding a custom condition for obtaining this entry using ZenScript // In this case - only if the player is in creative mode entryThree.addCondition(function(player as IPlayer) { return player.creative; }); - /stagetable silentaward