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

Function setConstraint

plugins/workflow.cpp:1477–1501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1475}
1476
1477static int setConstraint(lua_State *L)
1478{
1479 auto token = luaL_checkstring(L, 1);
1480 bool by_count = lua_toboolean(L, 2);
1481 int count = luaL_optint(L, 3, -1);
1482 int gap = luaL_optint(L, 4, -1);
1483
1484 color_ostream &out = *Lua::GetOutput(L);
1485 update_data_structures(out);
1486
1487 ItemConstraint *icv = get_constraint(out, token);
1488 if (!icv)
1489 luaL_error(L, "invalid constraint: %s", token);
1490
1491 if (!lua_isnil(L, 2))
1492 icv->setGoalByCount(by_count);
1493 if (!lua_isnil(L, 3))
1494 icv->setGoalCount(count);
1495 if (!lua_isnil(L, 4))
1496 icv->setGoalGap(gap);
1497
1498 process_constraints(out);
1499 push_constraint(L, icv);
1500 return 1;
1501}
1502
1503static int getCountHistory(lua_State *L)
1504{

Callers

nothing calls this directly

Calls 9

lua_tobooleanFunction · 0.85
update_data_structuresFunction · 0.85
get_constraintFunction · 0.85
luaL_errorFunction · 0.85
process_constraintsFunction · 0.85
push_constraintFunction · 0.85
setGoalByCountMethod · 0.80
setGoalCountMethod · 0.80
setGoalGapMethod · 0.80

Tested by

no test coverage detected