diff options
| author | Petr Mrázek | 2012-03-01 00:01:24 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-03-01 00:01:24 +0100 |
| commit | 07b4044336176e8277f3adaa2e03c406e77b6b76 (patch) | |
| tree | 9019b2ea3ff92b8c77dc464c46d8026d63bbd7ac /needs_porting/treedump.py | |
| parent | 1f2782d5b86ee62d821ec0c7e33833048fc06b20 (diff) | |
| download | dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.gz dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.bz2 dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.xz | |
Nuke more!
Diffstat (limited to 'needs_porting/treedump.py')
| -rw-r--r-- | needs_porting/treedump.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/needs_porting/treedump.py b/needs_porting/treedump.py new file mode 100644 index 00000000..f6017c94 --- /dev/null +++ b/needs_porting/treedump.py @@ -0,0 +1,52 @@ +from context import Context, ContextManager + +cm = ContextManager("Memory.xml") +df = cm.get_single_context() + +df.attach() + +gui = df.gui +veg = df.vegetation +mps = df.maps +mat = df.materials + +x, y, z = gui.get_cursor_coords() + +num_veg = veg.start() + +if x == -30000: + print "----==== Trees ====----" + + for i in xrange(num_veg): + t = veg.read(i) + + print "%d/%d/%d, %d:%d" % (t.x, t.y, t.z, t.type, t.material) +else: + #new method, gets the list of trees in a block. can show farm plants + if mps.start(): + pos_tuple = (x, y, z) + trees = mps.read_vegetation(x / 16, y / 16, z) + + if trees is not None: + for t in trees: + if (t.x, t.y, t.z) == pos_tuple: + print "----==== Tree at %d/%d/%d ====----" % pos_tuple + print str(t) + break + mps.finish() + + #old method, get the tree from the global vegetation vector. can't show farm plants + for i in xrange(num_veg): + t = veg.read(i) + + if (t.x, t.y, t.z) == pos_tuple: + print "----==== Tree at %d/%d/%d ====----" % pos_tuple + print str(t) + break + +veg.finish() + +df.detach() + +print "Done. Press any key to continue" +raw_input()
\ No newline at end of file |
