| 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) { |
nothing calls this directly
no test coverage detected