AutoSyndrome: added smart arguments for location, worker id, and reaction id.

develop
expwnent 2013-01-01 23:56:31 -05:00
parent a4dc79565a
commit b320fb25f3
3 changed files with 62 additions and 5 deletions

@ -180,7 +180,7 @@ void processJob(color_ostream& out, void* jobPtr) {
if ( job->job_type != df::job_type::CustomReaction )
return;
df::reaction* reaction = NULL;
for ( size_t a = 0; a < df::global::world->raws.reactions.size(); a++ ) {
df::reaction* candidate = df::global::world->raws.reactions[a];
@ -250,14 +250,38 @@ void processJob(color_ostream& out, void* jobPtr) {
if ( foundCommand ) {
if ( commandStr == "" )
commandStr = *clazz;
else
args.push_back(*clazz);
} else if ( *clazz == "command" ) {
else {
stringstream bob;
if ( *clazz == "\\LOCATION" ) {
bob << job->pos.x;
args.push_back(bob.str());
bob.str("");
bob.clear();
bob << job->pos.y;
args.push_back(bob.str());
bob.str("");
bob.clear();
bob << job->pos.z;
args.push_back(bob.str());
bob.str("");
bob.clear();
} else if ( *clazz == "\\WORKER_ID" ) {
bob << workerId;
args.push_back(bob.str());
} else if ( *clazz == "\\REACTION_INDEX" ) {
bob << reaction->index;
args.push_back(bob.str());
} else {
args.push_back(*clazz);
}
}
} else if ( *clazz == "\\COMMAND" ) {
foundCommand = true;
}
}
if ( commandStr != "" ) {
out.print("Running command thingy.");
Core::getInstance().runCommand(out, commandStr, args);
}
//check that the syndrome applies to that guy

@ -19,6 +19,7 @@ DFHACK_PLUGIN(rprobe rprobe.cpp)
DFHACK_PLUGIN(nestboxes nestboxes.cpp)
DFHACK_PLUGIN(vshook vshook.cpp)
DFHACK_PLUGIN(eventExample eventExample.cpp)
DFHACK_PLUGIN(printArgs printArgs.cpp)
IF(UNIX)
DFHACK_PLUGIN(ref-index ref-index.cpp)
ENDIF()

@ -0,0 +1,32 @@
#include "Console.h"
#include "Core.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include <iostream>
using namespace DFHack;
using namespace std;
command_result printArgs (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("printArgs");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
"printArgs", "Print the arguments given.",
printArgs, false
));
return CR_OK;
}
command_result printArgs (color_ostream &out, std::vector <std::string> & parameters)
{
for ( size_t a = 0; a < parameters.size(); a++ ) {
out << "Argument " << (a+1) << ": \"" << parameters[a] << "\"" << endl;
}
return CR_OK;
}