-
Notifications
You must be signed in to change notification settings - Fork 9
/
mcpi_worlds.py.bak
131 lines (98 loc) · 3.52 KB
/
mcpi_worlds.py.bak
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
"""
MCPI Mobs Manipulator
Description :
this script is to manipulate Mobs into Minecraft Raspeberry Pi version
wellknown as MCPI.
Here the possible task you can do :
-List of existing Mobs into the world (by default 0)
-add mobs
-display details about mobs.
-remove mobs
Author : Skeleton
Contact :
Date & Version : May 2016 / beta0.1
Updates :
How does it work ?
type the following command :
>>> get_current_user()
'pi'
>>> make_MCPI_path()
'/home/pi/.minecraft/games/com.mojang/minecraftWorlds'
>>> mcpi_directory = make_MCPI_path()
>>> checkMCPI_World(mcpi_directory)
['/home/pi/.minecraft/games/com.mojang/minecraftWorlds',
'/home/pi/.minecraft/games/com.mojang/minecraftWorlds/world----',...]
>>> mcpi_worlds = checkMCPI_World(mcpi_directory)
>>> selectMCPI_World(mcpi_worlds)
List of MCPI worlds
[0] /home/pi/.minecraft/games/com.mojang/minecraftWorlds
[1] /home/pi/.minecraft/games/com.mojang/minecraftWorlds/world----
[2] /home/pi/.minecraft/games/com.mojang/minecraftWorlds/world-
...
Select the MCPI world : 2
MCPI world selected
'/home/pi/.minecraft/games/com.mojang/minecraftWorlds/world'
"""
import os
import getpass #to define current user
mcpi_exist_path = ''
mcpi_select_world = ''
mcpi_directory = ''
def get_current_user():
return getpass.getuser()
def make_MCPI_path():
'''
Output : the proper path of MCPI world according user
'''
global mcpi_directory
mcpi_user = get_current_user()
mcpi_directory = "/home/%s/.minecraft/games/com.mojang/minecraftWorlds" % (mcpi_user)
return mcpi_directory
def checkMCPI_World(mcpi_directory):
'''
Check the existing MCPI world
by default, MCPI folders for words is :
/home/pi/.minecraft/games/com.mojang/minecraftWorlds
Input : mcpi_directory = make_MCPI_path().
Output : will return a List
'''
os.walk(mcpi_directory)
mcpi_worlds = [x[0] for x in os.walk(mcpi_directory)]
#mcpi_worlds.remove('')
return mcpi_worlds
def selectMCPI_World(mcpi_worlds):
'''
Assist to select the existing MCPI world from existing ones.
Input : mcpi_worlds = checkMCPI_World(mcpi_directory).
Output : return a string for selected folder path.
'''
while True:
path_id = 1
print 'List of MCPI worlds'
for i in mcpi_worlds[1:]:
print '[%d] %s' % (path_id, i)
path_id += 1
if mcpi_worlds == []:
print "ERROR: There is currently no world created under your account. "
print "Path : \n %s" % (mcpi_directory)
print "Selection aborted but you can still manully use commands."
break
#MCPIworld_choice = int(raw_input('Select the MCPI world : '))
MCPIworld_choice = input('Select the MCPI world : ')
#assert (mcpi_worlds[MCPIworld_choice]), "Wrong selection ! Please try again."
try:
mcpi_worlds[MCPIworld_choice]
except IndexError:
print 'Wrong selection ! Please try again. \n'
else:
print '\n MCPI world selected :\n' + str(mcpi_worlds[MCPIworld_choice])
return mcpi_worlds[MCPIworld_choice]
def renameMCPI_World(mcpi_selected_world):
'''
input : mcpi_selected_world = selectMCPI_World(mcpi_worlds)
output : none. (but changed the name)
'''
return "Sorry, not yet implemented."
def get_MCPI_Help():
return "Do you need help ?! Uh ? Go there then " +\
"https://github.com/Will-777/spawn_mobs_mcpi"