dfhack/library/python/deprecated/tools/shell.py

39 lines
1.1 KiB
Python

2010-05-02 20:37:13 -06:00
#!/usr/bin/python
import sys
import pydfhack
DF = pydfhack.API("Memory.xml")
2010-05-02 20:37:13 -06:00
DF.Attach()
pos = DF.position
maps = DF.maps
2010-05-03 04:19:40 -06:00
refc = dict(pydfhack=pydfhack, API=pydfhack.API, DF=DF, pos=pos, maps=maps)
cursor = pos.get_cursor()
msize = maps.get_size()
block = None
tile = None
2010-05-02 20:37:13 -06:00
if cursor:
2010-05-03 04:19:40 -06:00
block = maps.get_block(point=cursor)
if block:
tile = block.get_tile(point=cursor)
2010-05-02 20:37:13 -06:00
DF.Resume()
2010-05-03 04:19:40 -06:00
locs = dict(pydfhack=pydfhack, API=pydfhack.API, DF=DF, pos=pos, maps=maps, msize=msize, cursor=cursor, block=block, tile=tile)
2010-05-02 20:37:13 -06:00
banner = """DFHack Shell\n\n"""\
"""\tpydfhack = {pydfhack}\n"""\
"""\tAPI = {API}\n"""\
"""\tDF = {DF}\n"""\
"""\tpos = {pos}\n"""\
"""\tmaps = {maps}\n"""\
"""\tmsize = {msize}\n"""\
"""\tcursor = {cursor}\n"""\
2010-05-03 04:19:40 -06:00
"""\tblock = {block}\n"""\
"""\ttile = {tile}\n""".format(**locs)
2010-05-02 20:37:13 -06:00
from IPython.Shell import IPShellEmbed
shell = IPShellEmbed()
shell.set_banner(shell.IP.BANNER + '\n\n' + banner)
shell(local_ns=locs, global_ns={})
2010-05-03 04:19:40 -06:00
DF.Detach()