Repository navigation
Expand file tree
/
Copy pathexample_script.zs
More file actions
69 lines (62 loc) · 5.16 KB
/
Copy pathexample_script.zs
File metadata and controls
69 lines (62 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Example Code For RandomAdditions - GameStages x JEI
//
// Registers game stages as JEI entries, so players can search a stage name or id, click the entry
// and press U to read how the stage is obtained.
// Requires GameStages and FTBLib. The entry icon is ftblib:textures/icons/controller.png, the same
// controller icon FTBQ uses for its gamestage task and reward. Missing either mod disables the feature.
// Copy this file into your pack's scripts folder and replace the demo stage ids. The demo stages
// below will really show up in JEI if you leave them as they are.
// The demos keep the fully qualified name on purpose. The import is optional and only shortens it:
// import mods.random_additions.GameStage;
//========== Registration ==========
mods.random_additions.GameStage.register("bronze_age"); // Register a single stage. Use the exact id you pass to /gamestage add or player.addStage(...).
mods.random_additions.GameStage.registerAll(["age_iron", "age_gold"]); // Register several stages at once. JEI keeps the registration order and duplicates are ignored.
mods.random_additions.GameStage.register(" "); // Blank or whitespace-only ids are ignored, so names built at runtime are safe to pass through.
//========== Localization In The Script ==========
// Display name and description are language keys derived from the stage id:
// random_additions.game_stage.<stage>.name display name, falls back to the stage id when missing
// random_additions.game_stage.<stage>.tip first line of the description
// random_additions.game_stage.<stage>.tip.1 continuation lines, numbered from 1, reading stops at the first gap
// game.setLocalization writes into the same table as the language files, so both ways can be mixed freely.
game.setLocalization("random_additions.game_stage.bronze_age.name", "Bronze Age");
game.setLocalization("random_additions.game_stage.bronze_age.tip", "Smelt your first copper ingot");
game.setLocalization("random_additions.game_stage.bronze_age.tip.1", "Then craft a copper pickaxe");
//========== Localization In A Language File ==========
// The same keys can be shipped in a resource pack as assets/random_additions/lang/en_us.lang instead:
// random_additions.game_stage.bronze_age.name=Bronze Age
// random_additions.game_stage.bronze_age.tip=Smelt your first copper ingot
// random_additions.game_stage.bronze_age.tip.1=Then craft a copper pickaxe
// Language files survive a language switch, while game.setLocalization entries are wiped by Minecraft
// when the player changes the language in game, so prefer files for released packs.
//========== Localization Per Language ==========
// Two arguments apply to every language. Three arguments (lang, key, text) are only written when that
// language is active while the script loads.
game.setLocalization("en_us", "random_additions.game_stage.age_iron.name", "Iron Age");
game.setLocalization("zh_cn", "random_additions.game_stage.age_iron.name", "铁器时代");
game.setLocalization("random_additions.game_stage.age_iron.tip", "Mine your first iron ore");
game.setLocalization("random_additions.game_stage.age_iron.tip.1", "Remember to smelt it first");
//========== Colours And Longer Descriptions ==========
// Colour codes are the usual section sign plus a letter, and up to four wrapped lines fit on the page.
// Longer descriptions are cut off with "..." and shown in full when the mouse hovers over them.
mods.random_additions.GameStage.register("nether_age");
game.setLocalization("random_additions.game_stage.nether_age.name", "Nether Age");
game.setLocalization("random_additions.game_stage.nether_age.tip", "§7Build and light a nether portal");
game.setLocalization("random_additions.game_stage.nether_age.tip.1", "§7Find a fortress and get blaze rods");
game.setLocalization("random_additions.game_stage.nether_age.tip.2", "§7Trade with villagers back in the overworld");
//========== Without Localization ==========
mods.random_additions.GameStage.register("diamond_age"); // Without a .name key the entry is called "diamond_age", so searching the id still finds it.
// Without a .tip key either, the page prints the exact key you have to add, which is the line below.
// random_additions.game_stage.diamond_age.tip
//========== Result And Notes ==========
// In JEI, searching the localized name or the raw stage id finds the entry, and pressing U opens the
// page with the controller icon, the display name, the description lines, the stage id and a status
// line telling whether the local player already has the stage.
// The log prints one line per registered stage and one summary line when the entries are handed to JEI:
// [GameStage] registered stage 'bronze_age'
// [GameStage] pushed 5 stage entries to JEI
// When stages were registered but FTBLib or GameStages is missing, the log says so instead.
// Do not add a #loader directive to this file. CT runs loader-less scripts in the main pass, so a line
// like "Skipping file ... different loader" during the preinit pass is normal.
// Registering the same stage twice is ignored, and the first registration decides the order.
// GameStages has no global stage list and no config list either, so every stage you want to show has
// to be registered from a script like this one.