use a flag to avoid unnecessary saves
This commit is contained in:
parent
4a711abab0
commit
fce0df5a7d
22
mce.py
22
mce.py
@ -96,6 +96,7 @@ class mce(object):
|
|||||||
"debug",
|
"debug",
|
||||||
]
|
]
|
||||||
debug = False
|
debug = False
|
||||||
|
needsSave = False;
|
||||||
|
|
||||||
def readPoint(self, command, isPoint = True):
|
def readPoint(self, command, isPoint = True):
|
||||||
try:
|
try:
|
||||||
@ -209,7 +210,7 @@ class mce(object):
|
|||||||
tempSchematic = self.level.extractSchematic(box);
|
tempSchematic = self.level.extractSchematic(box);
|
||||||
self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), sourceSize), destPoint);
|
self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), sourceSize), destPoint);
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Cloned 0 blocks."
|
print "Cloned 0 blocks."
|
||||||
|
|
||||||
def _fill(self, command):
|
def _fill(self, command):
|
||||||
@ -240,6 +241,8 @@ class mce(object):
|
|||||||
box = BoundingBox(destPoint, destSize)
|
box = BoundingBox(destPoint, destSize)
|
||||||
self.level.fillBlocks(box, blockType)
|
self.level.fillBlocks(box, blockType)
|
||||||
|
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Filled {0} blocks.".format(box.volume)
|
print "Filled {0} blocks.".format(box.volume)
|
||||||
|
|
||||||
def _replace(self, command):
|
def _replace(self, command):
|
||||||
@ -278,6 +281,7 @@ class mce(object):
|
|||||||
box = BoundingBox(destPoint, destSize)
|
box = BoundingBox(destPoint, destSize)
|
||||||
self.level.fillBlocks(box, newBlockType, blockData = 0, blocksToReplace = [blockType])
|
self.level.fillBlocks(box, newBlockType, blockData = 0, blocksToReplace = [blockType])
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Replaced {0} blocks.".format(box.volume)
|
print "Replaced {0} blocks.".format(box.volume)
|
||||||
|
|
||||||
def _export(self, command):
|
def _export(self, command):
|
||||||
@ -326,6 +330,7 @@ class mce(object):
|
|||||||
self.level.copyBlocksFrom(importLevel, importLevel.getWorldBounds(), destPoint);
|
self.level.copyBlocksFrom(importLevel, importLevel.getWorldBounds(), destPoint);
|
||||||
|
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Imported {0} blocks.".format(importLevel.getWorldBounds().volume)
|
print "Imported {0} blocks.".format(importLevel.getWorldBounds().volume)
|
||||||
|
|
||||||
def _player(self, command):
|
def _player(self, command):
|
||||||
@ -352,6 +357,7 @@ class mce(object):
|
|||||||
point = self.readPoint(command)
|
point = self.readPoint(command)
|
||||||
self.level.setPlayerPosition(point, player)
|
self.level.setPlayerPosition(point, player)
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Moved player {0} to {1}".format(player, point)
|
print "Moved player {0} to {1}".format(player, point)
|
||||||
|
|
||||||
def _spawn(self, command):
|
def _spawn(self, command):
|
||||||
@ -366,6 +372,7 @@ class mce(object):
|
|||||||
|
|
||||||
self.level.setPlayerSpawnPosition(point);
|
self.level.setPlayerSpawnPosition(point);
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
print "Moved spawn point to ", map(int, point)
|
print "Moved spawn point to ", map(int, point)
|
||||||
else:
|
else:
|
||||||
print "Spawn point: ", self.level.playerSpawnPosition();
|
print "Spawn point: ", self.level.playerSpawnPosition();
|
||||||
@ -428,6 +435,8 @@ class mce(object):
|
|||||||
for entityID in sorted(removedEntities.keys()):
|
for entityID in sorted(removedEntities.keys()):
|
||||||
print " {0}: {1:6}".format(entityID, removedEntities[entityID]);
|
print " {0}: {1:6}".format(entityID, removedEntities[entityID]);
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
|
|
||||||
def _createchunks(self, command):
|
def _createchunks(self, command):
|
||||||
"""
|
"""
|
||||||
createChunks <point> <size>
|
createChunks <point> <size>
|
||||||
@ -450,6 +459,7 @@ class mce(object):
|
|||||||
|
|
||||||
print "Created {0} chunks." .format(len(self.level.presentChunks)-oldChunkCount)
|
print "Created {0} chunks." .format(len(self.level.presentChunks)-oldChunkCount)
|
||||||
|
|
||||||
|
self.needsSave = True;
|
||||||
|
|
||||||
def _deletechunks(self, command):
|
def _deletechunks(self, command):
|
||||||
"""
|
"""
|
||||||
@ -516,6 +526,7 @@ class mce(object):
|
|||||||
self.level.generateLights(chunks)
|
self.level.generateLights(chunks)
|
||||||
|
|
||||||
print "Relit 0 chunks."
|
print "Relit 0 chunks."
|
||||||
|
self.needsSave = True;
|
||||||
|
|
||||||
def _degrief(self, command):
|
def _degrief(self, command):
|
||||||
"""
|
"""
|
||||||
@ -549,6 +560,7 @@ class mce(object):
|
|||||||
self.level.materials.materialNamed("Stationary lava"),
|
self.level.materials.materialNamed("Stationary lava"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
self.needsSave = True;
|
||||||
|
|
||||||
def _quit(self, command):
|
def _quit(self, command):
|
||||||
"""
|
"""
|
||||||
@ -572,12 +584,14 @@ class mce(object):
|
|||||||
self._quit(command)
|
self._quit(command)
|
||||||
|
|
||||||
def _save(self, command):
|
def _save(self, command):
|
||||||
self.level.generateLights()
|
if self.needsSave:
|
||||||
self.level.saveInPlace();
|
self.level.generateLights()
|
||||||
|
self.level.saveInPlace();
|
||||||
|
self.needsSave = False;
|
||||||
|
|
||||||
def _load(self, command):
|
def _load(self, command):
|
||||||
"""
|
"""
|
||||||
load <filename>
|
load [ <filename> | <world number> ]
|
||||||
|
|
||||||
Loads another world, discarding all changes to this world.
|
Loads another world, discarding all changes to this world.
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user