summaryrefslogtreecommitdiff
path: root/library/LuaApi.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-04-26 18:51:39 +0400
committerAlexander Gavrilov2012-04-26 18:51:39 +0400
commit82a0e52a3eeb55d62dd51cf92b5b1b26d0cc4c66 (patch)
tree4388ab4532ab7dc4b47147cf2368de4a3ece00e6 /library/LuaApi.cpp
parent16ee049664765f2644d2ef83ad15d5ab101cd4e2 (diff)
downloaddfhack-82a0e52a3eeb55d62dd51cf92b5b1b26d0cc4c66.tar.gz
dfhack-82a0e52a3eeb55d62dd51cf92b5b1b26d0cc4c66.tar.bz2
dfhack-82a0e52a3eeb55d62dd51cf92b5b1b26d0cc4c66.tar.xz
Add api to check the walkable cache, and update flow_forbid in liquids.
Diffstat (limited to 'library/LuaApi.cpp')
-rw-r--r--library/LuaApi.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index 50749466..8855a50d 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -80,6 +80,17 @@ distribution.
using namespace DFHack;
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)
{
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 WRAPN(name, function) { #name, df::wrap_function(function,true) }
+/***** Translation module *****/
+
static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAPM(Translation, TranslateName),
{ NULL, NULL }
};
+/***** Gui module *****/
+
static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
WRAPM(Gui, getSelectedWorkshopJob),
WRAPM(Gui, getSelectedJob),
@@ -573,6 +588,8 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
{ NULL, NULL }
};
+/***** Job module *****/
+
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; }
@@ -609,6 +626,7 @@ static const luaL_Reg dfhack_job_funcs[] = {
{ NULL, NULL }
};
+/***** Units module *****/
static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, getContainer),
@@ -635,21 +653,7 @@ static int units_getNoblePositions(lua_State *state)
std::vector<Units::NoblePosition> np;
if (Units::getNoblePositions(&np, Lua::CheckDFObject<df::unit>(state,1)))
- {
- 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);
- }
- }
+ Lua::PushVector(state, np);
else
lua_pushnil(state);
@@ -662,6 +666,8 @@ static const luaL_Reg dfhack_units_funcs[] = {
{ NULL, NULL }
};
+/***** Items module *****/
+
static bool items_moveToGround(df::item *item, df::coord pos)
{
MapExtras::MapCache mc;
@@ -702,12 +708,15 @@ static const luaL_Reg dfhack_items_funcs[] = {
{ NULL, NULL }
};
+/***** Maps module *****/
+
static const LuaWrapper::FunctionReg dfhack_maps_module[] = {
WRAPN(getBlock, (df::map_block* (*)(int32_t,int32_t,int32_t))Maps::getBlock),
WRAPN(getTileBlock, (df::map_block* (*)(df::coord))Maps::getTileBlock),
WRAPM(Maps, getRegionBiome),
WRAPM(Maps, getGlobalInitFeature),
WRAPM(Maps, getLocalInitFeature),
+ WRAPM(Maps, canWalkBetween),
{ NULL, NULL }
};
@@ -715,6 +724,8 @@ static const luaL_Reg dfhack_maps_funcs[] = {
{ NULL, NULL }
};
+/***** Burrows module *****/
+
static bool burrows_isAssignedBlockTile(df::burrow *burrow, df::map_block *block, int x, int y)
{
return Burrows::isAssignedBlockTile(burrow, block, df::coord2d(x,y));