I have a readable block file (.blk) that is converted to a .txt file (from War Thunder). I’d like to parse the content in this file so that they are easy to access in my Python script.
Here’s what such a block file looks like:
<code>areas{
spawn_zone{
type:t="Sphere"
tm:m=[[9.70537, 0, 0] [0, 9.70537, 0] [0, 0, 9.70537] [2881.52, 75.8896, 182.321]]
objLayer:i=0
props{}
}
</code>
<code>areas{
spawn_zone{
type:t="Sphere"
tm:m=[[9.70537, 0, 0] [0, 9.70537, 0] [0, 0, 9.70537] [2881.52, 75.8896, 182.321]]
objLayer:i=0
props{}
}
</code>
areas{
spawn_zone{
type:t="Sphere"
tm:m=[[9.70537, 0, 0] [0, 9.70537, 0] [0, 0, 9.70537] [2881.52, 75.8896, 182.321]]
objLayer:i=0
props{}
}
How can I parse it so that I can access the different parts in my script? The optimal goal is to be able to type something along the lines of areas.spawn_zone.type
and it would return "Sphere"
Keep in mind a block file has a lot of clauses but they are identifiable by name – areas{...}
, units{...}
etc, so it needs to account for that.