-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathturm.py
executable file
·116 lines (83 loc) · 2.66 KB
/
turm.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
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
import sys
import math
import numpy as np
import os
import miney
import miney_toolbox as mtb
if not miney.is_miney_available():
raise miney.MinetestRunError("Please start Minetest with the miney game")
if not "MINETEST_USER" in os.environ:
print("Please specific the player name in the 'MINETEST_USER' env variable.")
exit(1)
if not "MINETEST_PASSWORD" in os.environ:
print("Please specific the player name in the 'MINETEST_PASSWORD' env variable.")
exit(1)
#mt = mt.Minetest( "localhost", "playername", "password", port= 29999 )
mt = miney.Minetest("localhost",
os.environ['MINETEST_USER'], os.environ['MINETEST_PASSWORD'] )
playername= ""
hoehe_turm= 22
hoehe_dach= 10
hoehe_etage= 5
material_wand= "wool:orange"
material_dach= "wool:grey"
# playername must be given
if len(sys.argv) > 1:
playername= sys.argv[1]
else:
print( "Playername not given, exit" )
print( "Available players are" )
for p in mt.player:
print( p )
exit(1)
if len(sys.argv) > 2:
hoehe_turm= int(sys.argv[2])
if len(sys.argv) > 3:
hoehe_dach= int(sys.argv[3])
if len(sys.argv) > 4:
hoehe_etage= int(sys.argv[4])
# materials can be given optionally
if len(sys.argv) > 5:
material_wand= sys.argv[5]
if len(sys.argv) > 6:
material_dach= sys.argv[6]
player= mt.player[playername]
X= np.array([1,0,0])
Y= np.array([0,1,0])
Z= np.array([0,0,1])
# Position des Spielers
P= np.array( mtb.pos_as_int( player ) )
print(P)
# Liste von Blöcken zum generieren
bloecke_wand= []
bloecke_innen= []
breite=10
tiefe=10
# Wände hochmauern als Schleife, mit Etage alle soundso viel Reihen
for y in range(0,hoehe_turm):
A= + X*breite//2 + Z*tiefe//2 + Y*y
B= + X*breite//2 - Z*tiefe//2 + Y*y
C= - X*breite//2 - Z*tiefe//2 + Y*y
D= - X*breite//2 + Z*tiefe//2 + Y*y
mtb.line( mt, P, A, B, material_wand )
mtb.line( mt, P, B, C, material_wand )
mtb.line( mt, P, C, D, material_wand )
mtb.line( mt, P, D, A, material_wand )
if 0 == y%hoehe_etage:
for x in range(-breite//2,breite//2):
E= X*x - Z*tiefe//2 + Y*y
F= X*x + Z*tiefe//2 + Y*y
mtb.line( mt, P, E, F, material_wand )
# Dach hochmauern
breite_dach= breite+4
S= Y*(hoehe_turm+hoehe_dach)
for l in range(-breite_dach//2,breite_dach//2+1):
A= + X*breite_dach//2 + Z*l + Y*(hoehe_turm)
B= - X*breite_dach//2 + Z*l + Y*(hoehe_turm)
C= + X*l - Z*breite_dach//2 + Y*(hoehe_turm)
D= + X*l + Z*breite_dach//2 + Y*(hoehe_turm)
mtb.line( mt, P, A, S, material_dach )
mtb.line( mt, P, B, S, material_dach )
mtb.line( mt, P, C, S, material_dach )
mtb.line( mt, P, D, S, material_dach )