Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: problem getting xml value into lua  (Read 1223 times)

Bo-Rufus CMVII

  • Bay Watcher
    • View Profile
problem getting xml value into lua
« on: March 14, 2014, 06:59:23 pm »

How come this works:

Code: [Select]
local something = v.body.components
but this doesn't:

Code: [Select]
local something = v.body.size_info
The former runs just fine, but the latter causes the script to bomb off with:

Code: [Select]
Cannot read field unit.T_body.size_info: not found.

Here's the definition from df.units.xml, with what I suppose to be the relevant lines indicated:
Code: [Select]
        <compound name='body'>
            <compound name='components' type-name='body_component_info'/>     <-------------------------------


            <stl-vector name='wounds'>
                <pointer type-name='unit_wound'/>
            </stl-vector>
            <int32_t name='wound_next_id' init-value='1'/>

            <static-array name='unk_39c' count='10'>
                <int32_t init-value='-1'/>
            </static-array>

            <pointer name='body_plan' type-name='caste_body_info'/>

            <int16_t name='weapon_bp' refers-to='$$._parent.body_plan.body_parts[$]' init-value='-1'/>

            <static-array type-name='unit_attribute' name='physical_attrs'
                          count='6' index-enum='physical_attribute_type'/>

            <compound name='size_info' type-name='body_size_info'/>      <-------------------------------

            <uint32_t name='blood_max'/>
            <uint32_t name='blood_count'/>

            <int32_t name='infection_level'
                      comment='GETS_INFECTIONS_FROM_ROT sets; DISEASE_RESISTANCE reduces; >=300 causes bleeding'/>

            <stl-vector name='spatters'>
                <pointer type-name='unit_spatter'/>
            </stl-vector>
        </compound>

I've stared at it until I'm crosseyed, and don't see any difference between the declarations, or any typos in my code.  Does the ordering within 'body' require use of a different syntax in lua?

Thanks.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: problem getting xml value into lua
« Reply #1 on: March 15, 2014, 01:44:25 am »

It might be that you are using dfhack r4 (or worse r3) and the xmls from github. They are out-of-sync because we need to rebuild dfhack itself to update. To see what fields a thing has, either "printall(X)" or use "gui/gm-editor X". It will probably be named unkown or something along those lines.

Bo-Rufus CMVII

  • Bay Watcher
    • View Profile
Re: problem getting xml value into lua
« Reply #2 on: March 15, 2014, 02:50:49 am »

Thanks.  Both identify themselves as r3, but printall shows something different from the xml.

Luckily there are some comments about the mathematical relations in the xml, and the numbers I get with printall suggest that they're the same thing, so I think it's just a renaming.  That means I can finish the script, but it probably won't be fully portable.
Logged