Add 'help' options to a bunch of commands.

develop
Petr Mrázek 2011-08-09 01:50:22 +02:00
parent 8fd437dbc1
commit cc19180ac0
7 changed files with 108 additions and 20 deletions

@ -21,7 +21,7 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("cleanmap","Cleans the map from various substances. Options: 'snow' for removing snow, 'mud' for mud.",cleanmap)); commands.push_back(PluginCommand("cleanmap","Cleans the map from various substances.",cleanmap));
return CR_OK; return CR_OK;
} }
@ -37,12 +37,26 @@ DFhackCExport command_result cleanmap (Core * c, vector <string> & parameters)
bool snow = false; bool snow = false;
bool mud = false; bool mud = false;
bool help = false;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "snow") if(parameters[i] == "snow")
snow = true; snow = true;
else if(parameters[i] == "mud") else if(parameters[i] == "mud")
mud = true; mud = true;
else if(parameters[i] == "help" ||parameters[i] == "?")
{
help = true;
}
}
if(help)
{
c->con.print("This command cleans the coverings from the map. Snow and mud are ignored by default.\n"
"Options:\n"
"snow - also remove snow\n"
"mud - also remove mud\n"
);
return CR_OK;
} }
c->Suspend(); c->Suspend();
vector<DFHack::t_spattervein *> splatter; vector<DFHack::t_spattervein *> splatter;

@ -22,9 +22,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("colonies", commands.push_back(PluginCommand("colonies",
"List or change wild colonies (ants hills and such)\ "List or change wild colonies (ants hills and such)",
\n Options: 'kill' = destroy all colonies\
\n 'bees' = change all colonies to honey bees",
colonies)); colonies));
return CR_OK; return CR_OK;
} }
@ -43,6 +41,7 @@ DFhackCExport command_result colonies (Core * c, vector <string> & parameters)
{ {
bool destroy = false; bool destroy = false;
bool convert = false; bool convert = false;
bool help = false;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
@ -50,8 +49,20 @@ DFhackCExport command_result colonies (Core * c, vector <string> & parameters)
destroy = true; destroy = true;
else if(parameters[i] == "bees") else if(parameters[i] == "bees")
convert = true; convert = true;
else if(parameters[i] == "help" || parameters[i] == "?")
{
help = true;
}
}
if(help)
{
c->con.print("Without any options, this command lists all the vermin colonies present.\n"
"Options:\n"
"kill - destroy colonies\n"
"bees - turn colonies into honey bees\n"
);
return CR_OK;
} }
if (destroy && convert) if (destroy && convert)
{ {
c->con.printerr("Kill or make bees? DECIDE!\n"); c->con.printerr("Kill or make bees? DECIDE!\n");

@ -51,7 +51,17 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
bool dirty= false; bool dirty= false;
int count=0; int count=0;
int countbad=0; int countbad=0;
for(int i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("This command does two things:\n"
"* If there are any ramps designated for removal, thyw will be instantly removed.\n"
"* Any ramps that don't have their counterpart will be removed (fixes bugs with caveins)\n"
);
return CR_OK;
}
}
c->Suspend(); c->Suspend();
DFHack::Maps *Mapz = c->getMaps(); DFHack::Maps *Mapz = c->getMaps();

@ -166,6 +166,16 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
DFHack::Maps * Maps; DFHack::Maps * Maps;
DFHack::Gui * Position; DFHack::Gui * Position;
for(int i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("This tool allows placing magma, water and other similar things.\n"
"It is interactive and further help is available when you run it.\n"
);
return CR_OK;
}
}
Brush * brush = new RectangleBrush(1,1); Brush * brush = new RectangleBrush(1,1);
string brushname = "point"; string brushname = "point";
bool end = false; bool end = false;

@ -48,7 +48,7 @@ enum do_what
do_extirpate do_extirpate
}; };
static bool getoptions( vector <string> & parameters, bool & shrubs, bool & trees) static bool getoptions( vector <string> & parameters, bool & shrubs, bool & trees, bool & help)
{ {
for(int i = 0;i < parameters.size();i++) for(int i = 0;i < parameters.size();i++)
{ {
@ -65,6 +65,10 @@ static bool getoptions( vector <string> & parameters, bool & shrubs, bool & tree
trees = true; trees = true;
shrubs = true; shrubs = true;
} }
else if(parameters[i] == "help" || parameters[i] == "?")
{
help = true;
}
else else
{ {
return false; return false;
@ -79,8 +83,21 @@ static bool getoptions( vector <string> & parameters, bool & shrubs, bool & tree
* And he cursed the plants and trees for their bloodless wood, turning them into ash and smoldering ruin. * And he cursed the plants and trees for their bloodless wood, turning them into ash and smoldering ruin.
* Armok was pleased and great temples were built by the dwarves, for they shared his hatred for trees and plants. * Armok was pleased and great temples were built by the dwarves, for they shared his hatred for trees and plants.
*/ */
static command_result immolations (Core * c, do_what what, bool shrubs, bool trees) static command_result immolations (Core * c, do_what what, bool shrubs, bool trees, bool help)
{ {
static const char * what1 = "destroys";
static const char * what2 = "burns";
if(help)
{
c->con.print("Without any options, this command %s a plant under the cursor.\n"
"Options:\n"
"shrubs - affect all shrubs\n"
"trees - affect all trees\n"
"all - affect all plants\n",
what == do_immolate? what2 : what1
);
return CR_OK;
}
c->Suspend(); c->Suspend();
DFHack::Maps *maps = c->getMaps(); DFHack::Maps *maps = c->getMaps();
if (!maps->Start()) if (!maps->Start())
@ -158,10 +175,10 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters) DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters)
{ {
bool shrubs = false, trees = false; bool shrubs = false, trees = false, help = false;
if(getoptions(parameters,shrubs,trees)) if(getoptions(parameters,shrubs,trees,help))
{ {
return immolations(c,do_immolate,shrubs,trees); return immolations(c,do_immolate,shrubs,trees, help);
} }
else else
{ {
@ -172,10 +189,10 @@ DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters
DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters) DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters)
{ {
bool shrubs = false, trees = false; bool shrubs = false, trees = false, help = false;
if(getoptions(parameters,shrubs,trees)) if(getoptions(parameters,shrubs,trees, help))
{ {
return immolations(c,do_extirpate,shrubs,trees); return immolations(c,do_extirpate,shrubs,trees, help);
} }
else else
{ {
@ -186,7 +203,14 @@ DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameter
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
{ {
//uint32_t x_max = 0, y_max = 0, z_max = 0; for(int i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("This command turns all living saplings into full-grown trees.\n");
return CR_OK;
}
}
c->Suspend(); c->Suspend();
DFHack::Maps *maps = c->getMaps(); DFHack::Maps *maps = c->getMaps();
Console & con = c->con; Console & con = c->con;

@ -125,7 +125,7 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use parameter 'all' to show hidden resources.",prospector)); commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use option 'all' to show hidden resources.",prospector));
return CR_OK; return CR_OK;
} }
@ -141,10 +141,23 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
bool showSlade = true; bool showSlade = true;
bool showTemple = true; bool showTemple = true;
Console & con = c->con; Console & con = c->con;
if(parameters.size() && parameters[0] == "all") for(int i = 0; i < parameters.size();i++)
{
if (parameters[0] == "all")
{ {
showHidden = true; showHidden = true;
} }
else if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("Prints a big list of all the present minerals.\n"
"By default, only the visible part of the map is scanned.\n"
"\n"
"Options:\n"
"all - Scan the whole map, as if it was revealed.\n"
);
return CR_OK;
}
}
uint32_t x_max = 0, y_max = 0, z_max = 0; uint32_t x_max = 0, y_max = 0, z_max = 0;
c->Suspend(); c->Suspend();
DFHack::Maps *maps = c->getMaps(); DFHack::Maps *maps = c->getMaps();

@ -25,8 +25,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
commands.clear(); commands.clear();
commands.push_back(PluginCommand("weather", commands.push_back(PluginCommand("weather",
"Print the weather map or change weather.\ "Print the weather map or change weather.\
\n Options: 'lock'/'unlock' = disallow game from changing weather\ \n Options: 'snow' = make it snow, 'rain' = make it rain.\
\n 'snow' = make it snow, 'rain' = make it rain.\
\n 'clear' = clear the sky",weather)); \n 'clear' = clear the sky",weather));
return CR_OK; return CR_OK;
} }
@ -44,6 +43,7 @@ DFhackCExport command_result weather (Core * c, vector <string> & parameters)
bool snow = false; bool snow = false;
bool rain = false; bool rain = false;
bool clear = false; bool clear = false;
bool help = false;
for(int i = 0; i < parameters.size();i++) for(int i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "rain") if(parameters[i] == "rain")
@ -56,6 +56,12 @@ DFhackCExport command_result weather (Core * c, vector <string> & parameters)
lock = true; lock = true;
else if(parameters[i] == "unlock") else if(parameters[i] == "unlock")
unlock = true; unlock = true;
else if(parameters[i] == "help" || parameters[i] == "?")
help = true;
}
if(help)
{
} }
if(lock && unlock) if(lock && unlock)
{ {