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

Function units_getFocusPenalty

library/LuaApi.cpp:2451–2468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2449}
2450
2451int32_t units_getFocusPenalty(lua_State *L) {
2452 auto unit = Lua::GetDFObject<df::unit>(L, 1);
2453 Units::need_type_set needs;
2454 auto top = lua_gettop(L);
2455 if (top < 2) {
2456 luaL_argerror(L, 2, "Expected at least one need type");
2457 } else {
2458 for (int i = 2; i <= top; ++i) {
2459 try {
2460 needs.set(luaL_checkint(L, i));
2461 } catch ([[maybe_unused]] const std::out_of_range &e) {
2462 luaL_argerror(L, i, "Expected a need type");
2463 }
2464 }
2465 Lua::Push(L, Units::getFocusPenalty(unit, needs));
2466 }
2467 return 1;
2468}
2469
2470static const luaL_Reg dfhack_units_funcs[] = {
2471 { "getPosition", units_getPosition },

Callers

nothing calls this directly

Calls 4

lua_gettopFunction · 0.85
luaL_argerrorFunction · 0.85
PushFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected