-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcustom.ts
132 lines (116 loc) · 2.84 KB
/
custom.ts
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//% block="HOC 2020" weight=200 color=#d83b01
namespace hoc2020 {
/**
* Agent interact forward
*/
//% block="toggle lever"
export function flipLever() {
agent.interact(FORWARD)
}
/**
* Agent place Iron Bars
*/
//% block="place iron bars down"
export function placeFence() {
agent.setItem(IRON_BARS, 1, 1)
agent.place(DOWN)
}
/**
* Agent till soil
*/
//% block="till and move forward %n times"
//% n.defl=1
export function tillSoil(n: number): void{
for (let i = 0; i < n; i++){
agent.till(UP)
player.execute(
"execute @c ~ ~ ~ detect ~ ~-1 ~ dirt 0 setblock ~ ~-1 ~ farmland 2"
)
agent.move(FORWARD,1)
}
}
/**
* Agent place wood down
*/
//% block="move and place wood %n times"
//% n.defl=1
export function placePlanks(n: number): void{
for (let i = 0; i < n; i++){
agent.move(FORWARD, 1)
agent.setItem(PLANKS_OAK, 1, 1)
agent.place(DOWN)
}
}
/**
* Agent place rail down
*/
//% block="place rail below"
export function placeRails(){
agent.setItem(RAIL, 1, 1)
agent.place(DOWN)
}
/**
* Lead ravager
*/
//% block="lead ravager %n forward"
//% n.defl=1
export function leadRavager(n: number): void{
for (let i = 0; i < n; i++){
agent.move(FORWARD,1)
//loops.pause(200)
}
}
/**
* Agent move
*/
//% block="agent move %d by %n"
//% n.defl=1
export function moveAgent(d: SixDirection, n: number): void{
for (let i = 0; i < n; i++){
agent.move(d,1)
}
}
/**
* Agent move up
*/
//% block="agent climb %n up"
//% n.defl=1
export function agentClimb(n: number): void{
for (let i = 0; i < n; i++){
agent.move(UP,1)
}
}
/**
* Give player sapling
*/
//% block="accept gift"
export function acceptGift(){
mobs.give(
mobs.target(LOCAL_PLAYER),
OAK_SAPLING,
1
)
}
/**
* Turn the Agent
*/
//% block="turn agent %t"
export function turnAgent(t: TurnDirection): void{
agent.turn(t);
}
}
//% block="HOC 2020 Cont" weight=200 color=#569138
namespace hoc2020Different {
/**
* Repeat code the specified number of times
*/
//% block="repeat $n times"
//% n.defl=2
//% handlerStatement=1
//% draggableParameters="reporter"
export function customRepeatLoop(n: number, handler: () => void) {
for (let i = 0; i < n; i++){
handler();
}
}
}