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

Function df_changeitem

plugins/changeitem.cpp:84–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 bool change_subtype, string new_subtype);
83
84command_result df_changeitem(color_ostream &out, vector <string> & parameters)
85{
86 bool here = false;
87 bool info = false;
88 bool force = false;
89
90 bool change_material = false;
91 string new_material = "none";
92
93 bool change_subtype = false;
94 string new_subtype = "NONE";
95
96 bool change_quality = false;
97 int new_quality = 0;
98
99 for (size_t i = 0; i < parameters.size(); i++)
100 {
101 string & p = parameters[i];
102
103 if (p == "help" || p == "?")
104 {
105 return CR_WRONG_USAGE;
106 }
107 else if (p == "here")
108 {
109 here = true;
110 }
111 else if (p == "info")
112 {
113 info = true;
114 }
115 else if (p == "force")
116 {
117 force = true;
118 }
119 else if (p == "material" || p == "m" )
120 {
121 // must be followed by material RAW id
122 // (string like 'INORGANIC:GRANITE', 'PLANT:MAPLE:WOOD', ...)
123 if(i == parameters.size()-1)
124 {
125 out.printerr("no material specified!\n");
126 return CR_WRONG_USAGE;
127 }
128 change_material = true;
129 new_material = parameters[i+1];
130 i++;
131 }
132 else if (p == "quality" || p == "q")
133 {
134 // must be followed by numeric quality (allowed: 0-5)
135 if(i == parameters.size()-1)
136 {
137 out.printerr("no quality specified!\n");
138 return CR_WRONG_USAGE;
139 }
140 string & q = parameters[i+1];
141 // meh. should use a stringstream instead. but it's only 6 numbers

Callers

nothing calls this directly

Calls 7

describeQualityFunction · 0.85
changeitem_executeFunction · 0.85
getSelectedItemFunction · 0.85
BlockAtMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected