stones.py sort-of works

develop
Petr Mrázek 2010-04-28 23:48:50 +02:00
parent 61c5e36537
commit c0ae0840db
3 changed files with 29 additions and 12 deletions

@ -199,7 +199,24 @@ inline bool ReadNamesOnly(Process* p, uint32_t address, vector<t_matgloss> & nam
bool Materials::ReadInorganicMaterials (vector<t_matgloss> & inorganic)
{
return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("mat_inorganics"), inorganic );
Process * p = d->owner;
DfVector <uint32_t> p_matgloss (p, d->owner->getDescriptor()->getAddress ("mat_inorganics"));
uint32_t size = p_matgloss.size();
inorganic.clear();
inorganic.reserve (size);
for (uint32_t i = 0; i < size;i++)
{
t_matgloss mat;
p->readSTLString (p_matgloss[i], mat.id, 128);
//p->readSTLString (p_matgloss[i] + mat_name, mat.name, 128);
mat.name[0] = 0;
mat.fore = 0;
mat.back = 0;
mat.bright = 0;
inorganic.push_back(mat);
}
return true;
}
bool Materials::ReadOrganicMaterials (vector<t_matgloss> & organic)

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import pydfhack
DF = pydfhack.API("Memory.xml")
DF = pydfhack._API("Memory.xml")
if DF.Attach():
success,stones = DF.ReadStoneMatgloss()
if success:
Mats = DF.materials
stones = Mats.Read_Inorganic_Materials()
print "Dumping all stone"
for matgloss in stones:
print "ID %s, name %s" % (matgloss.id, matgloss.name)