本文整理匯總了Python中region.Region.name方法的典型用法代碼示例。如果您正苦於以下問題:Python Region.name方法的具體用法?Python Region.name怎麽用?Python Region.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類region.Region
的用法示例。
在下文中一共展示了Region.name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: modify_lvl
# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import name [as 別名]
def modify_lvl(lvl, opts):
# tileset
if opts.newtileset:
if not os.path.exists(opts.newtileset):
print "*** tileset file '%s' does not exist" % opts.newtileset
sys.exit(1)
try:
nt = BMPFile(file(opts.newtileset))
except:
print "*** error reading tileset"
sys.exit(1)
lvl.bmp = nt
print "using tileset from %s" % mq(opts.newtileset)
if nt.width != 304 or nt.height != 160 or nt.depth != 8:
print "WARNING: new tileset isn't 304x160 at 8 bpp"
# tiles
for tilespec in opts.newtiles:
try:
x, y, t = map(int, tilespec.split(','))
except:
print "*** bad tile option: '%s' (should be 'x,y,type')" % tilespec
sys.exit(1)
lvl.set_tile(x, y, t)
print "set tile at %d,%d to %d" % (x, y, t)
# attributes
for attr in opts.attrs:
try:
k, v = attr.split('=', 1)
except:
print "*** bad attribute option: '%s' (should be 'key=value')" % attr
sys.exit(1)
lvl.set_attr(k, v)
print "setting attribute %s to %s" % (mq(k), mq(v))
for k in opts.attrs_to_del:
lvl.del_attr(k)
print "removing attribute %s" % (mq(k))
# regions
for rname in opts.regs_to_del:
r = lvl.find_region(rname)
if r:
lvl.regions.remove(r)
print "removing region %s" % (mq(rname))
elif opts.allowmissing:
print "can't find region %s, continuing" % mq(rname)
else:
print "*** can't find region %s" % mq(rname)
sys.exit(1)
for rname in opts.newregs:
r = Region([('rNAM', rname)])
lvl.regions.append(r)
print "created region %s" % (mq(rname))
for spec in opts.regs_to_ren:
try:
old, new = spec.split('=')
except:
print "*** bad renregion option: '%s' (should be 'oldname=newname')" % spec
sys.exit(1)
r = lvl.find_region(old)
if not r:
print "*** can't find region %s" % mq(old)
sys.exit(1)
r.name = new
print "renaming region %s to %s" % (mq(old), mq(new))
for flag in all_simple_flags:
for spec in getattr(opts, 'regs_to_set_' + flag):
try:
rname, state = spec.split('=')
state = int(state)
except:
print "*** bad %s option: '%s' (should be 'region=0/1')" % (flag, spec)
sys.exit(1)
r = lvl.find_region(rname)
if not r:
print "*** can't find region %s" % mq(rname)
sys.exit(1)
setattr(r, flag, state)
if state:
print "turned on %s for region %s" % (flag, mq(rname))
else:
print "turned off %s for region %s" % (flag, mq(rname))
for spec in opts.regs_to_set_aw:
try:
rname, xyarena = spec.split('=')
xyarena = xyarena.split(',')
#.........這裏部分代碼省略.........