-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsphere.py
executable file
·59 lines (45 loc) · 1.63 KB
/
sphere.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
#!/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= ""
material= "default:snowblock"
# playername must be given
if len(sys.argv) > 1:
playername= sys.argv[1]
else:
print( f"call as {sys.argv[0]} <playername> <radius> <up> [<material>]" )
print( "Playername not given, exit" )
print( "Available players are" )
for p in mt.player:
print( p )
exit(1)
player= mt.player[playername]
# if start and stop are not given print the players position and direction of view
if len(sys.argv) > 3:
r= float( sys.argv[2] )
h= float( sys.argv[3] )
if len(sys.argv) > 4:
material= sys.argv[4]
mtb.sphere( mt, mtb.pos_as_int( player ), r, h, material )
else:
print( f"call as {sys.argv[0]} {sys.argv[1]} <radius> <up> [<material>]" )
print( "" )
print( f"Info: Player {playername}" )
print( " Position ", mtb.pos_as_int(player) )
print( " Direction ", player.look_horizontal, player.look_vertical )
print( " Quadrant ", mtb.quadrant( player ) )