-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.mcscript
More file actions
81 lines (70 loc) · 2.19 KB
/
main.mcscript
File metadata and controls
81 lines (70 loc) · 2.19 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
70
71
72
73
74
75
76
77
78
79
80
81
pack-info: "example pack" "example_pack" "ep" "Example pack used for debugging" true both; #Partial comment
#def hp:update;
#This will set up a simple scoreboard objective.
entity int score = 0;
#This will set up an objective, but accessible from anywhere (using "fake player" mechanics)
global int x = 1;
#All references to y will be replaced by a literal for the value in the datapack.
constant int y = 3;
#Literal string
constant string s = "hello";
#Variables that are not of type "int" will be stored as nbt.
global desc="variable description\nsecond line" string str = "Hi";
#Decimal precision specified in the diamond
entity float<2> f = 0.53f;
#Different Precision
constant float<1> fl = 0.5f;
#Use tags for entity arrays
constant entity[] enemies = [@e[type=zombie], someones_username];
constant entity e = @e[sort=nearest];
#require fake_pack;
constant string s1 = "\"escaped string\" <--this should be part of that";
"#this is not a comment.";
single-line {this is a single-line statement};
#Run when the data pack is loaded or reloaded
on load {
#Try calling the same function in different ways
go();
main.go();
example_pack:main.go();
#Insert a literal command into the datapack
/say "example pack loaded <y> <y.json> <e> <x> <<y>>! <<f>> <no_exist>}";
/say "3<<5"
};
#Priority setting to customize the order in which tick functions are called
priority=-1 on tick {
comment("This comment will appear in the generated data pack.}");
#execute clause - will execute as the nearest player
as entity @p {
#increments x by one for the player executed as
#x++;
};
as entity @s {
/say hi;
}
#will execute if the literal command succeeds
if (/literal command;) {
/say "test passed";
str = "hello";
};
at @p {
#switch statement syntax
switch (x) {
case 1:
/fill ~ ~ ~ stone;
break;
};
};
};
#Add a listener for carrot on a sick use. Compatible with any editable scoreboard statistic.
id="used_c_stick" on used:carrot_on_a_stick {
#For loop.
for (i,1,5) {
#"<i>" will be replaced by the current value of i.
/say <i>;
};
};
#Function
function desc="Start the game" go() {
/say start;
};