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

@ -19,11 +19,11 @@ namespace DFHack
struct t_descriptor_color struct t_descriptor_color
{ {
char id[128]; // id in the raws char id[128]; // id in the raws
float r; float r;
float v; float v;
float b; float b;
char name[128]; //displayed name char name[128]; //displayed name
}; };
struct t_matglossPlant struct t_matglossPlant

@ -199,7 +199,24 @@ inline bool ReadNamesOnly(Process* p, uint32_t address, vector<t_matgloss> & nam
bool Materials::ReadInorganicMaterials (vector<t_matgloss> & inorganic) 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) bool Materials::ReadOrganicMaterials (vector<t_matgloss> & organic)

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