forked from juedwards/MinecraftEducationPythonExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.py
89 lines (72 loc) · 2.11 KB
/
house.py
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
# House Builder for MakeCode Python
# @JustinEducation
# 22 Feb 2023
# Set gameplay
gameplay.set_weather(CLEAR)
gameplay.time_set(DayTime.DAY)
def on_on_chat():
# set wall length (size) and height.
size = 4
walls = 4
height = 2
#start at player
agent.teleport_to_player()
start_position = agent.get_position()
# get STONE as resource for walls
agent.set_slot(1)
agent.set_item(STONE,64,1)
#build walls
counter_height = 0
while counter_height < height:
counter_walls = 0
while counter_walls < walls:
counter_size = 0
while counter_size < size:
if agent.detect(AgentDetection.BLOCK, FORWARD):
agent.destroy(FORWARD)
agent.move(FORWARD, 1)
agent.place(BACK)
counter_size +=1
agent.turn(TurnDirection.LEFT)
counter_walls +=1
agent.move(UP,1)
agent.place(DOWN)
counter_height +=1
#position for roof
agent.move(BACK, 1)
agent.move(RIGHT, 1)
base = size+2
if base % 2 == 0:
height = (base / 2) + 1
else:
height = base/2
#set counters for build
index = 0
sides = 0
# Add oak steps as resource for roof
agent.set_slot(2)
agent.set_item(OAK_WOOD_STAIRS,64,2)
#build roof
while index < height:
sides = 0
while sides < 4:
counter = 0
while counter < base:
if agent.detect(AgentDetection.BLOCK, FORWARD):
agent.destroy(FORWARD)
agent.move(RIGHT,1)
agent.turn_left()
agent.place(FORWARD)
agent.turn_right()
agent.move(FORWARD, 1)
agent.move(LEFT,1)
counter += 1
agent.turn(TurnDirection.LEFT)
sides += 1
agent.move(UP, 1)
agent.place(DOWN)
agent.move(LEFT,1)
agent.move(FORWARD,1)
base -= 2
index += 1
player.on_chat("house", on_on_chat)