From 0daafef690d6a9e44f7caa7f61b89a63a3870cf9 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
A material info record has fields:
+type, index, material
+DF material code pair, and a reference to the material object.
+mode
+One of 'builtin', 'inorganic', 'plant', 'creature'.
+inorganic, plant, creature
+If the material is of the matching type, contains a reference to the raw object.
+figure
+For a specific creature material contains a ref to the historical figure.
+Functions:
+dfhack.matinfo.decode(type,index)
+Looks up material info for the given number pair; if not found, returs nil.
+....decode(matinfo), ....decode(item), ....decode(obj)
+Uses matinfo.type/matinfo.index, item getter vmethods, +or obj.mat_type/obj.mat_index to get the code pair.
+dfhack.matinfo.find(token[,token...])
+Looks up material by a token string, or a pre-split string token sequence.
+dfhack.matinfo.getToken(...), info:getToken()
+Applies decode and constructs a string token.
+info:toString([temperature[,named]])
+Returns the human-readable name at the given temperature.
+info:getCraftClass()
+Returns the classification used for craft skills.
+info:matches(obj)
+Checks if the material matches job_material_category or job_item.
+Thin wrappers around C++ functions, similar to the ones for virtual methods.
dfhack.TranslateName(name,in_english,only_last_name)
@@ -768,7 +812,7 @@ However, currently every entry has a 180+-byte dead-weight overhead.dfhack.gui.getSelectedWorkshopJob(silent)
When a job is selected in 'q' mode, returns the job, else @@ -797,7 +841,7 @@ The is_bright boolean actually seems to invert the brightness.
dfhack.job.cloneJobStruct(job)
Creates a deep copy of the given job.
@@ -817,7 +861,7 @@ The is_bright boolean actually seems to invert the brightness.dfhack.units.getVisibleName(unit)
Returns the name visible in game, accounting for false identities.
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 45680f8ef..f1d86580a 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -42,6 +42,7 @@ distribution. #include "modules/Job.h" #include "modules/Translation.h" #include "modules/Units.h" +#include "modules/Materials.h" #include "LuaWrapper.h" #include "LuaTools.h" @@ -53,6 +54,13 @@ distribution. #include "df/building.h" #include "df/unit.h" #include "df/item.h" +#include "df/material.h" +#include "df/historical_figure.h" +#include "df/plant_raw.h" +#include "df/creature_raw.h" +#include "df/inorganic_raw.h" +#include "df/dfhack_material_category.h" +#include "df/job_material_category.h" #include