mcarcady / dfhack-client-python Goto Github PK
View Code? Open in Web Editor NEWPython DFHack RPC client
Python DFHack RPC client
Hello,
First I would like to thank you for putting up this work. I am struggling a bit with the interface.
Basically I want to grab information about all ingame tiles of the currently opened Fortress with DFHack running in the background. Ideally, this would be a 3D matrix with each cell containing information about the type of the associated tile (air, rock, water, wood...), potentially with buildings, items and creatures in that tile.
I dug a bit in DFHack documentation and from what I understand tiles are gathered in blocks. So I was trying to use the GetBlockList function to see what I could get (and from what I see in https://github.com/DFHack/dfhack/blob/b954cd7a0d574fa92d7c9a26a9e2298ab9126959/plugins/remotefortressreader/remotefortressreader.cpp#L1395 it seems to access tile info).
Sadly the ouput has an empty field for the map_blocks and I don't really know if the interface is broken somehow or if I am doing something wrong.
I edited blendwarf.py with theses lines:
from RemoteFortressReader_pb2 import BlockRequest
from RemoteFortressReader_pb2 import BlockList
@remote(plugin='RemoteFortressReader')
async def GetBlockList(input: BlockRequest, output: BlockList): pass
and
# Input argument
blockRequest = BlockRequest()
# Values based on what I saw in GetMapInfo
blockRequest.min_x = 88
blockRequest.max_x = 90
blockRequest.min_y = 66
blockRequest.max_y = 68
blockRequest.min_z = -16
blockRequest.max_z = -14
# Reproducing the formulas of plugins/remotefortressreader/remotefortressreader.cpp
center_x = (blockRequest.min_x + blockRequest.max_x) / 2
center_y = (blockRequest.min_y + blockRequest.max_y) / 2
nb_points = ((blockRequest.max_x - center_x + 1) * 2) * ((blockRequest.max_y - center_y + 1) * 2)
blockRequest.blocks_needed = int(nb_points * (blockRequest.max_z - blockRequest.min_z))
# Output argument
blockList = BlockList()
# Call to function
print("Blocks: ", (await GetBlockList(blockRequest, blockList)))
print(blockList)
I just see Blocks: map_x: 89 map_y: 67
so the funtion is well-called and returns values, but nothing for the blocks.
Do you have any idea about what is wrong?
Thank you for your help,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.