diff --git a/docs/Lua API.rst b/docs/Lua API.rst index 6c4b7052e..0a253df9d 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -3797,6 +3797,7 @@ Native functions provided by the `buildingplan` plugin: * ``bool isPlannableBuilding(df::building_type type, int16_t subtype, int32_t custom)`` returns whether the building type is handled by buildingplan. * ``bool isPlanModeEnabled(df::building_type type, int16_t subtype, int32_t custom)`` returns whether the buildingplan UI is enabled for the specified building type. +* ``bool isPlannedBuilding(df::building *bld)`` returns whether the given building is managed by buildingplan. * ``void addPlannedBuilding(df::building *bld)`` suspends the building jobs and adds the building to the monitor list. * ``void doCycle()`` runs a check for whether buildlings in the monitor list can be assigned items and unsuspended. This method runs automatically twice a game day, so you only need to call it directly if you want buildingplan to do a check right now. * ``void scheduleCycle()`` schedules a cycle to be run during the next non-paused game frame. Can be called multiple times while the game is paused and only one cycle will be scheduled. diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index dedc89f62..aab308a3d 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -1024,6 +1024,10 @@ static bool isPlannableBuilding(df::building_type type, toBuildingTypeKey(type, subtype, custom)); } +static bool isPlannedBuilding(df::building *bld) { + return !!planner.getPlannedBuilding(bld); +} + static void addPlannedBuilding(df::building *bld) { planner.addPlannedBuilding(bld); } @@ -1049,6 +1053,7 @@ static void setSetting(std::string name, bool value) { DFHACK_PLUGIN_LUA_FUNCTIONS { DFHACK_LUA_FUNCTION(isPlanModeEnabled), DFHACK_LUA_FUNCTION(isPlannableBuilding), + DFHACK_LUA_FUNCTION(isPlannedBuilding), DFHACK_LUA_FUNCTION(addPlannedBuilding), DFHACK_LUA_FUNCTION(doCycle), DFHACK_LUA_FUNCTION(scheduleCycle), diff --git a/plugins/lua/buildingplan.lua b/plugins/lua/buildingplan.lua index 9659b4867..f640969b8 100644 --- a/plugins/lua/buildingplan.lua +++ b/plugins/lua/buildingplan.lua @@ -7,6 +7,7 @@ local _ENV = mkmodule('plugins.buildingplan') * void setSetting(string name, boolean value) * bool isPlanModeEnabled(df::building_type type, int16_t subtype, int32_t custom) * bool isPlannableBuilding(df::building_type type, int16_t subtype, int32_t custom) + * bool isPlannedBuilding(df::building *bld) * void addPlannedBuilding(df::building *bld) * void doCycle() * void scheduleCycle()