|
|
@ -80,6 +80,17 @@ distribution.
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack::LuaWrapper;
|
|
|
|
using namespace DFHack::LuaWrapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Lua::Push(lua_State *state, const Units::NoblePosition &pos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lua_createtable(state, 0, 3);
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, pos.entity);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "entity");
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, pos.assignment);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "assignment");
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, pos.position);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "position");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Lua::PushPosXYZ(lua_State *state, df::coord pos)
|
|
|
|
int Lua::PushPosXYZ(lua_State *state, df::coord pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!pos.isValid())
|
|
|
|
if (!pos.isValid())
|
|
|
@ -558,11 +569,15 @@ static void OpenModule(lua_State *state, const char *mname,
|
|
|
|
#define WRAP(function) { #function, df::wrap_function(function,true) }
|
|
|
|
#define WRAP(function) { #function, df::wrap_function(function,true) }
|
|
|
|
#define WRAPN(name, function) { #name, df::wrap_function(function,true) }
|
|
|
|
#define WRAPN(name, function) { #name, df::wrap_function(function,true) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Translation module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_module[] = {
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_module[] = {
|
|
|
|
WRAPM(Translation, TranslateName),
|
|
|
|
WRAPM(Translation, TranslateName),
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Gui module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
|
|
|
|
WRAPM(Gui, getSelectedWorkshopJob),
|
|
|
|
WRAPM(Gui, getSelectedWorkshopJob),
|
|
|
|
WRAPM(Gui, getSelectedJob),
|
|
|
|
WRAPM(Gui, getSelectedJob),
|
|
|
@ -573,6 +588,8 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Job module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static bool jobEqual(df::job *job1, df::job *job2) { return *job1 == *job2; }
|
|
|
|
static bool jobEqual(df::job *job1, df::job *job2) { return *job1 == *job2; }
|
|
|
|
static bool jobItemEqual(df::job_item *job1, df::job_item *job2) { return *job1 == *job2; }
|
|
|
|
static bool jobItemEqual(df::job_item *job1, df::job_item *job2) { return *job1 == *job2; }
|
|
|
|
|
|
|
|
|
|
|
@ -609,6 +626,7 @@ static const luaL_Reg dfhack_job_funcs[] = {
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Units module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_units_module[] = {
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_units_module[] = {
|
|
|
|
WRAPM(Units, getContainer),
|
|
|
|
WRAPM(Units, getContainer),
|
|
|
@ -635,21 +653,7 @@ static int units_getNoblePositions(lua_State *state)
|
|
|
|
std::vector<Units::NoblePosition> np;
|
|
|
|
std::vector<Units::NoblePosition> np;
|
|
|
|
|
|
|
|
|
|
|
|
if (Units::getNoblePositions(&np, Lua::CheckDFObject<df::unit>(state,1)))
|
|
|
|
if (Units::getNoblePositions(&np, Lua::CheckDFObject<df::unit>(state,1)))
|
|
|
|
{
|
|
|
|
Lua::PushVector(state, np);
|
|
|
|
lua_createtable(state, np.size(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < np.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lua_createtable(state, 0, 3);
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, np[i].entity);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "entity");
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, np[i].assignment);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "assignment");
|
|
|
|
|
|
|
|
Lua::PushDFObject(state, np[i].position);
|
|
|
|
|
|
|
|
lua_setfield(state, -2, "position");
|
|
|
|
|
|
|
|
lua_rawseti(state, -2, i+1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
lua_pushnil(state);
|
|
|
|
lua_pushnil(state);
|
|
|
|
|
|
|
|
|
|
|
@ -662,6 +666,8 @@ static const luaL_Reg dfhack_units_funcs[] = {
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Items module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static bool items_moveToGround(df::item *item, df::coord pos)
|
|
|
|
static bool items_moveToGround(df::item *item, df::coord pos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MapExtras::MapCache mc;
|
|
|
|
MapExtras::MapCache mc;
|
|
|
@ -702,12 +708,15 @@ static const luaL_Reg dfhack_items_funcs[] = {
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Maps module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_maps_module[] = {
|
|
|
|
static const LuaWrapper::FunctionReg dfhack_maps_module[] = {
|
|
|
|
WRAPN(getBlock, (df::map_block* (*)(int32_t,int32_t,int32_t))Maps::getBlock),
|
|
|
|
WRAPN(getBlock, (df::map_block* (*)(int32_t,int32_t,int32_t))Maps::getBlock),
|
|
|
|
WRAPN(getTileBlock, (df::map_block* (*)(df::coord))Maps::getTileBlock),
|
|
|
|
WRAPN(getTileBlock, (df::map_block* (*)(df::coord))Maps::getTileBlock),
|
|
|
|
WRAPM(Maps, getRegionBiome),
|
|
|
|
WRAPM(Maps, getRegionBiome),
|
|
|
|
WRAPM(Maps, getGlobalInitFeature),
|
|
|
|
WRAPM(Maps, getGlobalInitFeature),
|
|
|
|
WRAPM(Maps, getLocalInitFeature),
|
|
|
|
WRAPM(Maps, getLocalInitFeature),
|
|
|
|
|
|
|
|
WRAPM(Maps, canWalkBetween),
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -715,6 +724,8 @@ static const luaL_Reg dfhack_maps_funcs[] = {
|
|
|
|
{ NULL, NULL }
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** Burrows module *****/
|
|
|
|
|
|
|
|
|
|
|
|
static bool burrows_isAssignedBlockTile(df::burrow *burrow, df::map_block *block, int x, int y)
|
|
|
|
static bool burrows_isAssignedBlockTile(df::burrow *burrow, df::map_block *block, int x, int y)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Burrows::isAssignedBlockTile(burrow, block, df::coord2d(x,y));
|
|
|
|
return Burrows::isAssignedBlockTile(burrow, block, df::coord2d(x,y));
|
|
|
|