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

Function listConstraints

plugins/workflow.cpp:1419–1459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417}
1418
1419static 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
1461static int findConstraint(lua_State *L)
1462{

Callers

nothing calls this directly

Calls 11

lua_settopFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushnilFunction · 0.85
isSupportedJobFunction · 0.85
update_data_structuresFunction · 0.85
get_knownFunction · 0.85
push_constraintFunction · 0.85
push_count_historyFunction · 0.85
lua_setfieldFunction · 0.85
lua_rawsetiFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected