Heh, yeah, I'd love to see that stuff cleaned up, especially after having used the incredible pymclevel, a Python library for editing Minecraft worlds. I also noticed someone's thread asking for an "infinite dungeon generator," and got to thinking that it might be pretty fun to try and whip something up to do so.SpottedShroom wrote:Good to see you're still making improvements to the editor. Please allow me to make an unreasonable feature request. I'd love to see an API into the map interface, so that I could write code like this:
You should be able to at least do some of what you want... One of the bigger problems would be having to deal with the coordinate system yourself, which isn't very intuitive or easy to work with. Your example code can be more-or-less replicated like so, btw:
Code: Select all
#!/usr/bin/python
# vim: set expandtab tabstop=4 shiftwidth=4:
from eschalon.map import Map
from eschalon.smartdraw import SmartDraw
# Constants
mapname = 'testing'
book = 1
FLOOR_BRICK = 53
WALL_BRICK = 181
# Initialize a blank map
# Note that despite the name "load", this doesn't actually load from
# disk yet - you'd have to call "m.read()" to actually do that.
m = Map.load('%s.map' % (mapname), book)
if book == 1:
m.mapid = mapname
# Set this map as a "savegame" map, as opposed to a "global" map
m.set_savegame(True)
# Initialize our smartdraw system (for linking walls together)
sd = SmartDraw.new(book)
sd.set_map(m)
# Floor
for i in range(10, 21):
for j in range(10, 21):
m.squares[i][j].floorimg = FLOOR_BRICK
# Walls
for i in range(10, 20):
for j in [10, 20]:
m.squares[i][j].wall = 1
m.squares[i][j].wallimg = WALL_BRICK
sd.draw_wall(m.squares[i][j])
for i in [10, 20]:
for j in range(10, 20):
m.squares[i][j].wall = 1
m.squares[i][j].wallimg = WALL_BRICK
sd.draw_wall(m.squares[i][j])
# Write
m.write()
Code: Select all
cur_y = 10
for x in range(10, 15):
for y in [cur_y, cur_y+1]:
m.squares[y][x].wall = 1
m.squares[y][x].wallimg = WALL_BRICK
sd.draw_wall(m.squares[y][x])
cur_y += 2
I will see what I can do about cleaning all that up, providing some actually-useful API calls for walls and the like, integrating the smartdraw stuff, and providing actual documentation for it... That'll probably take a bit, though, and I probably won't target that until after 0.8.0.