New devel plugin - list counters for selected creature

develop
Quietust 2012-03-30 16:39:19 -05:00
parent 4d5aade389
commit 0f3ae4499f
2 changed files with 48 additions and 0 deletions

@ -14,4 +14,5 @@ DFHACK_PLUGIN(frozen frozen.cpp)
DFHACK_PLUGIN(dumpmats dumpmats.cpp) DFHACK_PLUGIN(dumpmats dumpmats.cpp)
#DFHACK_PLUGIN(tiles tiles.cpp) #DFHACK_PLUGIN(tiles tiles.cpp)
DFHACK_PLUGIN(regrass regrass.cpp) DFHACK_PLUGIN(regrass regrass.cpp)
DFHACK_PLUGIN(counters counters.cpp)

@ -0,0 +1,47 @@
// Show creature counter values
#include "Core.h"
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Gui.h"
#include "df/unit.h"
#include "df/unit_misc_trait.h"
using std::vector;
using std::string;
using namespace DFHack;
using namespace df::enums;
command_result df_counters (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;
df::unit *unit = Gui::getSelectedUnit(out);
if (!unit)
return CR_WRONG_USAGE;
auto &counters = unit->status.misc_traits;
for (size_t i = 0; i < counters.size(); i++)
{
auto counter = counters[i];
out.print("%i (%s): %i\n", counter->id, ENUM_KEY_STR(unit_misc_trait::T_id, counter->id).c_str(), counter->value);
}
return CR_OK;
}
DFHACK_PLUGIN("probe");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("counters",
"Display counters for currently selected creature",
df_counters));
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{
return CR_OK;
}