Skip to content

Commit

Permalink
expose if buildingplan is enabled to lua
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Sep 20, 2020
1 parent 9d3a168 commit c6111ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3616,8 +3616,9 @@ buildingplan

Native functions:

* ``bool isPlannableBuilding(df::building_type type)`` returns whether the building type is handled by buildingplan
* ``void addPlannedBuilding(df::building *bld)`` suspends the building jobs and adds the building to the monitor list
* ``bool isEnabled()`` returns whether the plugin is enabled.
* ``bool isPlannableBuilding(df::building_type type)`` returns whether the building type is handled 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.

burrows
Expand Down
5 changes: 5 additions & 0 deletions plugins/buildingplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan

// Lua API section

static bool isEnabled() {
return is_enabled;
}

static bool isPlannableBuilding(df::building_type type) {
return planner.isPlanableBuilding(type);
}
Expand All @@ -431,6 +435,7 @@ static void doCycle() {
}

DFHACK_PLUGIN_LUA_FUNCTIONS {
DFHACK_LUA_FUNCTION(isEnabled),
DFHACK_LUA_FUNCTION(isPlannableBuilding),
DFHACK_LUA_FUNCTION(addPlannedBuilding),
DFHACK_LUA_FUNCTION(doCycle),
Expand Down
1 change: 1 addition & 0 deletions plugins/lua/buildingplan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local _ENV = mkmodule('plugins.buildingplan')
Native functions:
* bool isEnabled()
* bool isPlannableBuilding(df::building_type type)
* void addPlannedBuilding(df::building *bld)
* void doCycle()
Expand Down

0 comments on commit c6111ba

Please sign in to comment.