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

Method collect_settings

plugins/stockflow.cpp:137–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135 }
136
137 bool collect_settings(building_stockpilest *sp) {
138 // Find strings representing the job to order, and the trigger condition.
139 // There might be a memory leak here; C++ is odd like that.
140 auto L = Lua::Core::State;
141 color_ostream_proxy out(Core::getInstance().getConsole());
142
143 CoreSuspender suspend;
144 Lua::StackUnwinder top(L);
145
146 if (!lua_checkstack(L, 2))
147 return false;
148
149 if (!Lua::PushModulePublic(out, L, "plugins.stockflow", "stockpile_settings"))
150 return false;
151
152 Lua::Push(L, sp);
153
154 if (!Lua::SafeCall(out, L, 1, 2))
155 return false;
156
157 if (!lua_isstring(L, -1))
158 return false;
159
160 current_trigger = lua_tostring(L, -1);
161 lua_pop(L, 1);
162
163 if (!lua_isstring(L, -1))
164 return false;
165
166 current_job = lua_tostring(L, -1);
167 lua_pop(L, 1);
168
169 stockpile_id = sp->id;
170
171 return true;
172 }
173
174 void draw(building_stockpilest *sp) {
175 if (sp->id != stockpile_id) {

Callers

nothing calls this directly

Calls 5

lua_checkstackFunction · 0.85
PushModulePublicFunction · 0.85
PushFunction · 0.85
SafeCallFunction · 0.85
lua_isstringFunction · 0.85

Tested by

no test coverage detected