-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterraformer.py
executable file
·105 lines (77 loc) · 2.86 KB
/
terraformer.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/python3
"""Maek arena."""
from subprocess import call
from time import sleep
GROUND_LEVEL = 56
def read_config(filename="SETTINGS.txt"):
pass
def get_square_params():
y_ground = 56#int(input("y_ground: "))
x = int(input("x: "))
z = int(input("z: "))
width = int(input("width: "))
length = width
height = 4#int(input("height: "))-1
material = input("material (no minecraft: prefix): ")
return {'x_1': x, 'z_1': z, 'y_1': y_ground,
'x_2': x+length, 'z_2': z+width, 'y_2': y_ground+height,
'material': material}
def get_rectanglular_perimeter(params):
commands = ["/fill {x_1} {y_1} {z_1} {x_2} {y_2} {z_2} minecraft:{material}".format(**params),
"/fill {x_1} {y_1} {z_1} {x_1} {y_2} {z_2} minecraft:{material}".format(**params),
"/fill {x_2} {y_1} {z_1} {x_2} {y_2} {z_2} minecraft:{material}".format(**params),
"/fill {x_1} {y_1} {z_2} {x_2} {y_2} {z_2} minecraft:{material}".format(**params)]
for _ in commands:
print(_, end="\n\n")
return commands
def get_rectanglular_prism(params):
commands = ["/fill {x_1} {y_1} {z_1} {x_2} {y_2} {z_2} minecraft:{material}".format(**params)]
for _ in commands:
print(_, end="\n\n")
return commands
def get_arena(params):
p_1 = params.copy()
p_2 = params.copy()
p_3 = params.copy()
# Walls
commands = get_rectanglular_prism(p_1)
# Floor
p_3['y_2'] = p_3['y_1'] = p_3['y_1'] - 1
commands += get_rectanglular_prism(p_3)
p_3['y_2'] = p_3['y_1'] = p_3['y_1'] - 4
commands += get_rectanglular_prism(p_3)
p_2['material'] = 'air'
# Arena
p_2['x_1'] += 1
p_2['x_2'] -= 1
p_2['z_1'] += 1
p_2['z_2'] -= 1
commands += get_rectanglular_prism(p_2)
# Room
p_1['material'] = 'air'
p_1['y_2'] = p_1['y_1'] - 2
p_1['y_1'] -= 4
commands += get_rectanglular_prism(p_1)
# Room
p_1['y_2'] = p_1['y_1'] - 2
p_1['y_1'] -= 4
commands += get_rectanglular_prism(p_1)
return commands
def send_command(command, session, pane=0, manager="tmux"):
if manager == "tmux":
call(["tmux", "send-keys", "-t" "{session}:{pane}".format(session=session, pane=pane),
command, "C-m"])
# screen -p 0 -S $session_name -X eval "stuff \015\"$*\"\015"
def send_commands(commands, session, pane=0):
"""Send a list of commands to the specified tmux session."""
for _ in commands:
if _ and _[0] != '#':
send_command(_, session, pane)
sleep(0.05)
def send_file(filename, session, pane=0):
"""Send a file of server commands to the specified tmux session."""
send_commands(open(filename, 'r').read().split('\n'), session, pane)
if __name__ == "__main__":
SESSION = input("tmux session: ")
send_file("examples/arena.txt", SESSION)
send_file("examples/mining.txt", SESSION)