| 1417 | } |
| 1418 | |
| 1419 | static int listConstraints(lua_State *L) |
| 1420 | { |
| 1421 | lua_settop(L, 2); |
| 1422 | auto job = Lua::CheckDFObject<df::job>(L, 1); |
| 1423 | bool with_history = lua_toboolean(L, 2); |
| 1424 | |
| 1425 | lua_pushnil(L); |
| 1426 | |
| 1427 | if (!enabled || (job && !isSupportedJob(job))) |
| 1428 | return 1; |
| 1429 | |
| 1430 | color_ostream &out = *Lua::GetOutput(L); |
| 1431 | update_data_structures(out); |
| 1432 | |
| 1433 | ProtectedJob *pj = NULL; |
| 1434 | if (job) |
| 1435 | { |
| 1436 | pj = get_known(job->id); |
| 1437 | if (!pj) |
| 1438 | return 1; |
| 1439 | } |
| 1440 | |
| 1441 | lua_newtable(L); |
| 1442 | |
| 1443 | auto &vec = (pj ? pj->constraints : constraints); |
| 1444 | |
| 1445 | for (size_t i = 0; i < vec.size(); i++) |
| 1446 | { |
| 1447 | push_constraint(L, vec[i]); |
| 1448 | |
| 1449 | if (with_history) |
| 1450 | { |
| 1451 | push_count_history(L, vec[i]); |
| 1452 | lua_setfield(L, -2, "history"); |
| 1453 | } |
| 1454 | |
| 1455 | lua_rawseti(L, -2, i+1); |
| 1456 | } |
| 1457 | |
| 1458 | return 1; |
| 1459 | } |
| 1460 | |
| 1461 | static int findConstraint(lua_State *L) |
| 1462 | { |
nothing calls this directly
no test coverage detected