From 09d91dcae12d7b504c0e3d396a0dba69181bd703 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sat, 6 Feb 2021 14:14:08 -0800 Subject: [PATCH] move alchemist-enabling logic to autohauler --- docs/Lua API.rst | 7 ++++--- plugins/autohauler.cpp | 21 +++++++++++++++++---- plugins/manipulator.cpp | 27 --------------------------- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index da5ac206b..928b3874e 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -1274,10 +1274,11 @@ Units module Returns whether the indicated labor is settable for the given unit. -* ``dfhack.units.setLaborValidity(unit_labor)`` +* ``dfhack.units.setLaborValidity(unit_labor, isValid)`` - Sets the given labor as valid for all playable units in the game (that is, for - all civilizations whose members can be residents of your fort). + Sets the given labor to the given (boolean) validity for all playable units in + the game (that is, for all civilizations whose members can be residents of + your fort). * ``dfhack.units.getNominalSkill(unit, skill[, use_rust])`` diff --git a/plugins/autohauler.cpp b/plugins/autohauler.cpp index 40d7452c7..7dd574f5f 100644 --- a/plugins/autohauler.cpp +++ b/plugins/autohauler.cpp @@ -565,10 +565,20 @@ static void cleanup_state() labor_infos.clear(); } +static void enable_alchemist(color_ostream &out) +{ + if (!Units::setLaborValidity(unit_labor::ALCHEMIST, true)) + { + // informational only; this is a non-fatal error + out.printerr("manipulator: Could not flag Alchemist as a valid skill; Alchemist will not" + " be settable from DF or DFHack labor management screens.\n"); + } +} + /** * Initialize the plugin labor lists */ -static void init_state() +static void init_state(color_ostream &out) { // This obtains the persistent data from the world save file config = World::GetPersistentData("autohauler/config"); @@ -656,6 +666,9 @@ static void init_state() reset_labor((df::unit_labor) i); } + // Allow Alchemist to be set in the labor-related UI screens so the player + // can actually use it as a flag without having to run Dwarf Therapist + enable_alchemist(out); } /** @@ -681,7 +694,7 @@ static void enable_plugin(color_ostream &out) cleanup_state(); // Initialize the plugin - init_state(); + init_state(out); } /** @@ -740,7 +753,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector