MCPcopy Create free account
hub / github.com/DFHack/dfhack / df_plant

Function df_plant

plugins/plant.cpp:525–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525command_result df_plant(color_ostream &out, vector<string> &parameters)
526{
527 plant_options options;
528 cuboid bounds;
529 df::coord pos_1, pos_2;
530 vector<int32_t> filter; // Unsorted
531
532 if (!Lua::CallLuaModuleFunction(out, "plugins.plant", "parse_commandline",
533 std::make_tuple(&options, &pos_1, &pos_2, &filter, parameters)))
534 {
535 return CR_WRONG_USAGE;
536 }
537 else if (options.plant_idx == -2)
538 { // Print all non-grass raw IDs ("plant list")
539 out.print("--- Shrubs ---\n");
540 for (auto p_raw : world->raws.plants.bushes)
541 out.print("{}: {}\n", p_raw->index, p_raw->id);
542
543 out.print("\n--- Saplings ---\n");
544 for (auto p_raw : world->raws.plants.trees)
545 out.print("{}: {}\n", p_raw->index, p_raw->id);
546
547 return CR_OK;
548 }
549 else if (options.force && !options.create)
550 {
551 out.printerr("Can't use --force without create!\n");
552 return CR_WRONG_USAGE;
553 }
554
555 bool by_type = options.shrubs || options.saplings || options.trees; // Remove only invalid plants otherwise
556 if (!options.del && (by_type || options.dead))
557 { // Don't use remove options outside remove
558 out.printerr("Can't use remove's options without remove!\n");
559 return CR_WRONG_USAGE;
560 }
561 else if (!by_type && options.dead)
562 { // Don't target dead plants while fixing invalid
563 out.printerr("Can't use --dead without targeting shrubs/saplings!\n"); // TODO: trees
564 return CR_WRONG_USAGE;
565 }
566 else if (options.del && options.age >= 0)
567 { // Can't set age with remove
568 out.printerr("Can't use --age with remove!\n");
569 return CR_WRONG_USAGE;
570 }
571 else if (options.trees)
572 { // TODO: implement
573 out.printerr("--trees not implemented!\n");
574 return CR_FAILURE;
575 }
576
577 DEBUG(log, out).print("pos_1 = ({}, {}, {})\npos_2 = ({}, {}, {})\n",
578 pos_1.x, pos_1.y, pos_1.z, pos_2.x, pos_2.y, pos_2.z);
579
580 if (!Core::getInstance().isMapLoaded())
581 {
582 out.printerr("Map not loaded!\n");

Callers

nothing calls this directly

Calls 10

CallLuaModuleFunctionFunction · 0.85
vector_getFunction · 0.85
df_createplantFunction · 0.85
df_growFunction · 0.85
df_removeplantFunction · 0.85
is_setMethod · 0.80
printMethod · 0.45
emptyMethod · 0.45
isValidMethod · 0.45
addPosMethod · 0.45

Tested by

no test coverage detected